public <T extends ConfigurationPersistenceService> T getConfigurationPersistenceService() { InternalLocator locator = InternalLocator.getLocator(); return locator == null ? null : (T) locator.getConfigurationPersistenceService(); }
public void updateLocalLocators() { List locators = Locator.getLocators(); for (int i = 0; i < locators.size(); i++) { InternalLocator l = (InternalLocator) locators.get(i); ServerLocator serverLocator = l.getServerLocatorAdvisee(); if (serverLocator != null) { serverLocator.updateLoad(location, load, this.clientIds); } } }
public boolean isSharedConfigurationRunning() { InternalLocator locator = InternalLocator.getLocator(); return locator != null && locator.isSharedConfigurationRunning(); }
@Override public Object processRequest(Object request) throws IOException { assert request instanceof SharedConfigurationStatusRequest; InternalLocator locator = InternalLocator.getLocator(); return locator.getSharedConfigurationStatus(); }
private void startColocatedJmxManagerLocator() { InternalLocator loc = InternalLocator.getLocator(); if (loc != null) { loc.startJmxManagerLocationService(this); } }
@Override public void execute(FunctionContext context) { Set<String> groups = (Set<String>) context.getArguments(); InternalLocator internalLocator = InternalLocator.getLocator(); logger.info("Received request for configuration: {}", groups); if (!internalLocator.isSharedConfigurationEnabled()) { String errorMessage = "The cluster configuration service is not enabled on this member."; logger.warn(errorMessage); if (internalLocator.isSharedConfigurationRunning()) { internalLocator.getConfigurationPersistenceService();
StartupMessageReplyProcessor proc = new StartupMessageReplyProcessor(dm, recipients); boolean isSharedConfigurationEnabled = false; if (InternalLocator.hasLocator()) { isSharedConfigurationEnabled = InternalLocator.getLocator().isSharedConfigurationEnabled(); new StartupMessage(InternalLocator.getLocatorStrings(), isSharedConfigurationEnabled);
newLocator = createLocator(port, loggingSession, logFile, logger, securityLogger, bindAddress, hostnameForClients, dsProperties, startDistributedSystem); newLocator.startPeerLocation(); newLocator.startDistributedSystem(); } catch (RuntimeException e) { newLocator.stop(); throw e; if (ids != null) { ids.getDistributionManager().addHostedLocators(ids.getDistributedMember(), getLocatorStrings(), newLocator.isSharedConfigurationEnabled()); newLocator.stop(); throw lce; if (sys != null) { try { newLocator.startServerLocation(sys); } catch (RuntimeException e) { newLocator.stop(); throw e; newLocator.endStartLocator(null); startedLocator = true; return newLocator; removeLocator(newLocator);
@Before public void setUp() { mockedResultSender = mock(ResultSender.class); mockedLocator = mock(InternalLocator.class); mockedFunctionContext = mock(FunctionContext.class); mockedConfigurationService = mock(InternalConfigurationPersistenceService.class); getClusterConfigurationFunction = new GetClusterConfigurationFunction(); when(mockedLocator.isSharedConfigurationEnabled()).thenReturn(true); when(mockedLocator.isSharedConfigurationRunning()).thenReturn(true); when(mockedFunctionContext.getResultSender()).thenReturn(mockedResultSender); when(mockedFunctionContext.getArguments()).thenReturn(Collections.emptySet()); PowerMockito.mockStatic(InternalLocator.class); when(InternalLocator.getLocator()).thenReturn(mockedLocator); }
StartupResponseWithVersionMessage(ClusterDistributionManager dm, int processorId, InternalDistributedMember recipient, String rejectionMessage, boolean responderIsAdmin) { super(dm, processorId, recipient, rejectionMessage, responderIsAdmin); version = GemFireVersion.getGemFireVersion(); this.hostedLocators = InternalLocator.getLocatorStrings(); InternalLocator locator = InternalLocator.getLocator(); if (locator != null) { this.isSharedConfigurationEnabled = locator.isSharedConfigurationEnabled(); } }
private static String getPortAsString(LocatorLauncher launcher) { if (InternalLocator.hasLocator()) { final InternalLocator locator = InternalLocator.getLocator(); final String portAsString = String.valueOf(locator.getPort()); if (isNotBlank(portAsString)) { return portAsString; } } return launcher.getPortAsString(); }
/** * Returns the locator if it exists in this JVM. Otherwise returns null. * * @return the locator that exists in this JVM; null if no locator. * @since GemFire 7.0 */ public static Locator getLocator() { return InternalLocator.getLocator(); }
private static String getBindAddressAsString(LocatorLauncher launcher) { if (InternalLocator.hasLocator()) { final InternalLocator locator = InternalLocator.getLocator(); final InetAddress bindAddress = locator.getBindAddress(); if (bindAddress != null) { if (isNotBlank(bindAddress.getHostAddress())) { return bindAddress.getHostAddress(); } } } return launcher.getBindAddressAsString(); }
private static String getLogFileCanonicalPath(LocatorLauncher launcher) { if (InternalLocator.hasLocator()) { final InternalLocator locator = InternalLocator.getLocator(); final File logFile = locator.getLogFile(); if (logFile != null && logFile.isFile()) { final String logFileCanonicalPath = tryGetCanonicalPathElseGetAbsolutePath(logFile); if (isNotBlank(logFileCanonicalPath)) { // this is probably not need but a // safe check none-the-less. return logFileCanonicalPath; } } } return launcher.getLogFileCanonicalPath(); }
if (locator != this && hasLocator()) { throw new IllegalStateException( "A locator can not be created because one already exists in this JVM."); if (isSharedConfigurationEnabled()) { this.configurationPersistenceService = new InternalConfigurationPersistenceService(newCache); startClusterManagementService(); startTcpServer(); startJmxManagerLocationService(newCache); endStartLocator(this.myDs); logger.info("Locator restart completed");
@Test public void executeShouldReturnExceptionWhenClusterConfigurationServiceIsEnabledButFailuresOccurWhileRetrievingIt() { when(mockedConfigurationService.createConfigurationResponse(any())) .thenThrow(new RuntimeException("Mocked Exception.")); when(mockedLocator.getConfigurationPersistenceService()).thenReturn(mockedConfigurationService); ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class); assertThatCode(() -> getClusterConfigurationFunction.execute(mockedFunctionContext)) .doesNotThrowAnyException(); verify(mockedResultSender).lastResult(argumentCaptor.capture()); Exception exceptionThrown = argumentCaptor.getValue(); assertThat(exceptionThrown).isInstanceOf(RuntimeException.class) .hasMessage("Mocked Exception."); }
public void startLocator() { try { // this will start a jmx manager and admin rest service by default locator = (InternalLocator) startLocatorAndDS(memberPort, null, properties); } catch (IOException e) { throw new UncheckedIOException(e); } // memberPort is by default zero, which translates to "randomly select an available port," // which is why it is updated here after being specified above. memberPort = locator.getPort(); DistributionConfig config = locator.getConfig(); jmxPort = config.getJmxManagerPort(); httpPort = config.getHttpServicePort(); if (config.getEnableClusterConfiguration()) { await() .untilAsserted(() -> assertTrue(locator.isSharedConfigurationRunning())); } }
try { this.startedLocator = InternalLocator.createLocator(locId.getPort(), NullLoggingSession.create(), null, logWriter, securityLogWriter, locId.getHost().getAddress(), locId.getHostnameForClients(), originalConfig.toProperties(), false); this.startedLocator.getConfig().setEnableClusterConfiguration(false); this.startedLocator.startPeerLocation(); startedPeerLocation = true; } finally { if (!startedPeerLocation) { this.startedLocator.stop();
if (isServerLocator()) { throw new IllegalStateException( String.format("Server location is already running for %s", new ServerLocator(getPort(), this.bindAddress, this.hostnameForClients, this.logFile, this.productUseLog, getConfig().getName(), distributedSystem, this.stats); this.handler.addHandler(LocatorListRequest.class, serverLocator); this.handler.addHandler(ClientConnectionRequest.class, serverLocator); this.serverLocator = serverLocator; if (!this.server.isAlive()) { startTcpServer();
if (InternalLocator.hasLocator()) { Locator loc = InternalLocator.getLocator(); handleLocatorStart(loc);