Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public synchronized void start(int port)
throw e;
}
}
Thread stdoutThread = pipeStreamToLog(process.getInputStream(), Level.INFO);
Thread stderrThread = pipeStreamToLog(process.getErrorStream(), Level.WARNING);
stdoutThread = pipeStreamToLog(process.getInputStream(), Level.INFO);
stderrThread = pipeStreamToLog(process.getErrorStream(), Level.WARNING);
isStopped = false;

shutdownHook =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ApiFuture<PrepareResponse> getFreshPlan() {
* Check the expiry of the current plan, if it's future is resolved. If we are within 1s of
* expiry, call startBackgroundRefresh with the version of the latest PrepareQuery.
*/
void backgroundRefreshIfNeeded() {
synchronized void backgroundRefreshIfNeeded() {
PrepareQueryState localState = this.currentState.get();
if (localState.maybeBackgroundRefresh().isPresent()) {
// We already have an ongoing refresh
Expand Down Expand Up @@ -183,7 +183,7 @@ void backgroundRefreshIfNeeded() {
* Returns the most recently refreshed PreparedQueryData. It may still be refreshing if the
* previous plan has expired.
*/
public PreparedQueryData getLatestPrepareResponse() {
public synchronized PreparedQueryData getLatestPrepareResponse() {
PrepareQueryState localState = currentState.get();
if (localState.maybeBackgroundRefresh().isPresent()
&& localState.maybeBackgroundRefresh().get().prepareFuture().isDone()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class BigtableCloudMonitoringExporter implements MetricExporter {
private final MetricServiceClient client;

private final AtomicReference<State> state;
private CompletableResultCode lastExportCode;
private AtomicReference<CompletableResultCode> lastExportCode = new AtomicReference<>();
private final AtomicBoolean exportFailureLogged = new AtomicBoolean(false);

private enum State {
Expand Down Expand Up @@ -149,8 +149,9 @@ public void close() {
public CompletableResultCode export(Collection<MetricData> metricData) {
Preconditions.checkState(state.get() != State.Closed, "Exporter is closed");

lastExportCode = doExport(metricData);
return lastExportCode;
CompletableResultCode result = doExport(metricData);
lastExportCode.set(result);
return result;
}

private CompletableResultCode doExport(Collection<MetricData> metricData) {
Expand Down Expand Up @@ -194,7 +195,7 @@ public void onFailure(Throwable throwable) {
RuntimeException asyncWrapper = new RuntimeException("export failed", throwable);
asyncWrapper.setStackTrace(stackTrace);

if (state.get() != State.Closing && state.get() != State.Closed) {
if (state.get() != State.Closing || state.get() != State.Closed) {
// ignore the export warning when client is shutting down
LOGGER.log(Level.WARNING, msg, asyncWrapper);
}
Expand Down Expand Up @@ -231,8 +232,8 @@ private List<ApiFuture<Empty>> exportTimeSeries(

@Override
public CompletableResultCode flush() {
if (lastExportCode != null) {
return lastExportCode;
if (lastExportCode.get() != null) {
return lastExportCode.get();
}
return CompletableResultCode.ofSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ synchronized void update(long value) {
weightedCount += weight;
}

double getMean() {
synchronized double getMean() {
return mean;
}

Expand Down
Loading