Java Code Examples for org.apache.curator.framework.state.ConnectionState#name()

The following examples show how to use org.apache.curator.framework.state.ConnectionState#name() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusResource.java    From Baragon with Apache License 2.0 5 votes vote down vote up
@GET
@NoAuth
public BaragonAgentStatus getStatus(@DefaultValue("false") @QueryParam("skipCache") boolean skipCache) {
  if (skipCache) {
    try {
      adapter.checkConfigs();
      errorMessage.set(Optional.<String>absent());
    } catch (InvalidConfigException e) {
      errorMessage.set(Optional.of(e.getMessage()));
    }
  }

  final ConnectionState currentConnectionState = connectionState.get();

  final String connectionStateString = currentConnectionState == null ? "UNKNOWN" : currentConnectionState.name();

  Optional<String> currentErrorMessage = errorMessage.get();
  Set<String> currentStateErrors = new HashSet<>(stateErrors);

  return new BaragonAgentStatus(loadBalancerConfiguration.getName(),
      !currentErrorMessage.isPresent(),
      currentErrorMessage,
      leaderLatch.hasLeadership(),
      mostRecentRequestId.get(),
      connectionStateString,
      agentMetadata,
      agentState.get(),
      currentStateErrors,
      directoryChangesListener.getErrorMessage());
}
 
Example 2
Source File: StatusManager.java    From Baragon with Apache License 2.0 5 votes vote down vote up
public BaragonServiceStatus getServiceStatus() {
  final ConnectionState currentConnectionState = connectionState.get();
  final String connectionStateString = currentConnectionState == null ? "UNKNOWN" : currentConnectionState.name();
  final long workerLagMs = System.currentTimeMillis() - workerLastStart.get();
  final long elbWorkerLagMs = System.currentTimeMillis() - elbWorkerLastStart.get();
  if (connectionStateString.equals("CONNECTED") || connectionStateString.equals("RECONNECTED")) {
    return new BaragonServiceStatus(leaderLatch.hasLeadership(), requestDatastore.getQueuedRequestCount(), workerLagMs, elbWorkerLagMs,connectionStateString, requestDatastore.getOldestQueuedRequestAge());
  } else {
    return new BaragonServiceStatus(leaderLatch.hasLeadership(), 0, workerLagMs, elbWorkerLagMs, connectionStateString, 0L);
  }
}