InternalLocator extends Locator implements ConnectListener, LogConfigSupplier { @VisibleForTesting void startClusterManagementService() throws IOException { startConfigurationPersistenceService(); AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion()); startClusterManagementService(internalCache, agentUtil); } @VisibleForTesting  InternalLocator(int port, LoggingSession loggingSession, File logFile,
      InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress,
      String hostnameForClients, Properties distributedSystemProperties,
      DistributionConfigImpl distributionConfig, Path workingDirectory); static InternalLocator getLocator(); static boolean hasLocator(); @Deprecated static InternalLocator createLocator(int port, LoggingSession loggingSession, File logFile,
      InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress,
      String hostnameForClients, Properties distributedSystemProperties,
      boolean startDistributedSystem); static InternalLocator createLocator(int port, LoggingSession loggingSession, File logFile,
      InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress,
      String hostnameForClients, Properties distributedSystemProperties, Path workingDirectory); static InternalLocator startLocator(int port, File logFile, InternalLogWriter logWriter,
      InternalLogWriter securityLogWriter, InetAddress bindAddress, boolean startDistributedSystem,
      Properties distributedSystemProperties, String hostnameForClients); static InternalLocator startLocator(int port, File logFile, InternalLogWriter logWriter,
      InternalLogWriter securityLogWriter, InetAddress bindAddress, boolean startDistributedSystem,
      Properties distributedSystemProperties, String hostnameForClients, Path workingDirectory); static boolean isDedicatedLocator(); boolean isSharedConfigurationEnabled(); boolean isSharedConfigurationRunning(); LocatorMembershipListener getLocatorMembershipListener(); @Deprecated LocatorMembershipListener getlocatorMembershipListener(); InternalConfigurationPersistenceService getConfigurationPersistenceService(); DistributionConfigImpl getConfig(); InternalCache getCache(); MembershipLocator<InternalDistributedMember> getMembershipLocator(); @Deprecated static InternalLocator startLocator(int locatorPort, File logFile,
      InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress,
      Properties distributedSystemProperties, boolean peerLocator, boolean serverLocator,
      String hostnameForClients, boolean b1); @Override void stop(); void stop(boolean forcedDisconnect, boolean stopForReconnect, boolean waitForDisconnect); boolean isStopped(); void waitToStop(); boolean isReconnected(); ClusterManagementService getClusterManagementService(); @Override DistributedSystem getDistributedSystem(); @Override boolean isPeerLocator(); @Override boolean isServerLocator(); ServerLocator getServerLocatorAdvisee(); @Override Integer getPort(); @Override LogConfig getLogConfig(); @Override StatisticsConfig getStatisticsConfig(); @Override void addLogConfigListener(LogConfigListener logConfigListener); @Override void removeLogConfigListener(LogConfigListener logConfigListener); SharedConfigurationStatusResponse getSharedConfigurationStatus(); @Override void onConnect(InternalDistributedSystem sys); static Collection<String> getLocatorStrings(); void startJmxManagerLocationService(InternalCache internalCache); boolean hasHandlerForClass(Class messageClass); static final int MAX_POOL_SIZE; static final int POOL_IDLE_TIMEOUT; static final String FORCE_LOCATOR_DM_TYPE; static final String INHIBIT_DM_BANNER; static final String LOCATORS_PREFERRED_AS_COORDINATORS; }
@Test public void startClusterManagementServiceWithRestServiceEnabledInvokesStartManager() throws Exception { when(distributionConfig.getEnableManagementRestService()).thenReturn(true); internalLocator.startClusterManagementService(cache, agentUtil); verify(managementService).startManager(); verify(httpService).addWebApplication(eq("/management"), any(), any()); }
@Test public void startClusterManagementServiceWithRunningManagerNeverInvokesStartManager() throws Exception { when(distributionConfig.getEnableManagementRestService()).thenReturn(true); when(managementService.isManager()).thenReturn(true); internalLocator.startClusterManagementService(cache, agentUtil); verify(managementService).isManager(); verify(managementService, never()).startManager(); verify(httpService).addWebApplication(eq("/management"), any(), any()); }
@Test public void startClusterManagementServiceWithRestServiceDisabledNeverInvokesStartManager() throws Exception { when(distributionConfig.getEnableManagementRestService()).thenReturn(false); internalLocator.startClusterManagementService(cache, agentUtil); verify(distributionConfig).getEnableManagementRestService(); verify(managementService, never()).startManager(); verify(httpService, never()).addWebApplication(eq("/management"), any(), any()); }
@Test public void startClusterManagementServiceWithRestServiceEnabledDoesNotThrowWhenStartManagerThrows() throws Exception { when(distributionConfig.getEnableManagementRestService()).thenReturn(true); RuntimeException startManagerEx = new RuntimeException("startManager failed"); doThrow(startManagerEx).when(managementService).startManager(); internalLocator.startClusterManagementService(cache, agentUtil); verify(managementService).startManager(); verify(httpService, never()).addWebApplication(eq("/management"), any(), any()); }