Search in sources :

Example 1 with SharedConfigurationStatusResponse

use of org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse in project geode by apache.

the class ClusterConfigurationService method createStatusResponse.

/**
   * Create a response containing the status of the Shared configuration and information about other
   * locators containing newer shared configuration data (if at all)
   * 
   * @return {@link SharedConfigurationStatusResponse} containing the
   *         {@link SharedConfigurationStatus}
   */
SharedConfigurationStatusResponse createStatusResponse() {
    SharedConfigurationStatusResponse response = new SharedConfigurationStatusResponse();
    response.setStatus(getStatus());
    response.addWaitingLocatorInfo(this.newerSharedConfigurationLocatorInfo);
    return response;
}
Also used : SharedConfigurationStatusResponse(org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse)

Example 2 with SharedConfigurationStatusResponse

use of org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse in project geode by apache.

the class InternalLocator method getSharedConfigurationStatus.

public SharedConfigurationStatusResponse getSharedConfigurationStatus() {
    ExecutorService es = this.myCache.getDistributionManager().getWaitingThreadPool();
    Future<SharedConfigurationStatusResponse> statusFuture = es.submit(new FetchSharedConfigStatus());
    SharedConfigurationStatusResponse response;
    try {
        response = statusFuture.get(5, TimeUnit.SECONDS);
    } catch (Exception e) {
        logger.info("Exception occurred while fetching the status {}", CliUtil.stackTraceAsString(e));
        response = new SharedConfigurationStatusResponse();
        response.setStatus(SharedConfigurationStatus.UNDETERMINED);
    }
    return response;
}
Also used : SharedConfigurationStatusResponse(org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse) ExecutorService(java.util.concurrent.ExecutorService) CancelException(org.apache.geode.CancelException) LocatorCancelException(org.apache.geode.distributed.internal.tcpserver.LocatorCancelException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 3 with SharedConfigurationStatusResponse

use of org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse in project geode by apache.

the class ClusterConfigurationStatusRetriever method fromLocator.

public static String fromLocator(String locatorHostName, int locatorPort) throws ClassNotFoundException, IOException {
    final StringBuilder buffer = new StringBuilder();
    try {
        final InetAddress networkAddress = InetAddress.getByName(locatorHostName);
        InetSocketAddress inetSockAddr = new InetSocketAddress(networkAddress, locatorPort);
        TcpClient client = new TcpClient();
        SharedConfigurationStatusResponse statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
        for (int i = 0; i < NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS; i++) {
            if (statusResponse.getStatus().equals(org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.STARTED) || statusResponse.getStatus().equals(org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.NOT_STARTED)) {
                statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                // Swallow the exception
                }
            } else {
                break;
            }
        }
        switch(statusResponse.getStatus()) {
            case RUNNING:
                buffer.append("\nCluster configuration service is up and running.");
                break;
            case STOPPED:
                buffer.append("\nCluster configuration service failed to start , please check the log file for errors.");
                break;
            case WAITING:
                buffer.append("\nCluster configuration service is waiting for other locators with newer shared configuration data.");
                Set<PersistentMemberPattern> pmpSet = statusResponse.getOtherLocatorInformation();
                if (!pmpSet.isEmpty()) {
                    buffer.append("\nThis locator might have stale cluster configuration data.");
                    buffer.append("\nFollowing locators contain potentially newer cluster configuration data");
                    for (PersistentMemberPattern pmp : pmpSet) {
                        buffer.append("\nHost : ").append(pmp.getHost());
                        buffer.append("\nDirectory : ").append(pmp.getDirectory());
                    }
                } else {
                    buffer.append("\nPlease check the log file for errors");
                }
                break;
            case UNDETERMINED:
                buffer.append("\nUnable to determine the status of shared configuration service, please check the log file");
                break;
            case NOT_STARTED:
                buffer.append("\nCluster configuration service has not been started yet");
                break;
            case STARTED:
                buffer.append("\nCluster configuration service has been started, but its not running yet");
                break;
        }
    } catch (Exception e) {
        // TODO fix this once Trac Bug #50513 gets fixed
        // NOTE this ClassCastException occurs if the a plain text TCP/IP connection is used to
        // connect to a Locator
        // configured with SSL.
        Gfsh.getCurrentInstance().logToFile(String.format("Failed to get the status of the Shared Configuration Service running on Locator (%1$s[%2$d])!", locatorHostName, locatorPort), e);
    }
    return buffer.toString();
}
Also used : SharedConfigurationStatusResponse(org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse) PersistentMemberPattern(org.apache.geode.internal.cache.persistence.PersistentMemberPattern) InetSocketAddress(java.net.InetSocketAddress) TcpClient(org.apache.geode.distributed.internal.tcpserver.TcpClient) SharedConfigurationStatusRequest(org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusRequest) InetAddress(java.net.InetAddress) IOException(java.io.IOException)

Aggregations

SharedConfigurationStatusResponse (org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse)3 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 ExecutorService (java.util.concurrent.ExecutorService)1 CancelException (org.apache.geode.CancelException)1 LockServiceDestroyedException (org.apache.geode.distributed.LockServiceDestroyedException)1 LocatorCancelException (org.apache.geode.distributed.internal.tcpserver.LocatorCancelException)1 TcpClient (org.apache.geode.distributed.internal.tcpserver.TcpClient)1 PersistentMemberPattern (org.apache.geode.internal.cache.persistence.PersistentMemberPattern)1 SharedConfigurationStatusRequest (org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusRequest)1