Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5D042200BC5 for ; Mon, 7 Nov 2016 20:51:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5BA7D160AEC; Mon, 7 Nov 2016 19:51:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 123D7160AF9 for ; Mon, 7 Nov 2016 20:51:48 +0100 (CET) Received: (qmail 59179 invoked by uid 500); 7 Nov 2016 19:51:48 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 59165 invoked by uid 99); 7 Nov 2016 19:51:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2016 19:51:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1E3DAC0C69 for ; Mon, 7 Nov 2016 19:51:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id JCdmfMkLJ543 for ; Mon, 7 Nov 2016 19:51:25 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 7AC5D60D72 for ; Mon, 7 Nov 2016 19:51:11 +0000 (UTC) Received: (qmail 55312 invoked by uid 99); 7 Nov 2016 19:51:09 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2016 19:51:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D7E95F12EF; Mon, 7 Nov 2016 19:51:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Mon, 07 Nov 2016 19:51:31 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [24/61] [partial] incubator-geode git commit: Added Spotless plugin to enforce formatting standards. Added Google Java Style guide formatter templates, removed existing formatter templates. archived-at: Mon, 07 Nov 2016 19:51:51 -0000 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java index aba79d2..59fce55 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.admin.internal; @@ -54,22 +52,21 @@ import static org.apache.geode.distributed.ConfigurationProperties.*; /** * Represents a GemFire distributed system for remote administration/management. * - * @since GemFire 3.5 + * @since GemFire 3.5 */ -public class AdminDistributedSystemImpl -implements org.apache.geode.admin.AdminDistributedSystem, - org.apache.geode.internal.admin.JoinLeaveListener, - org.apache.geode.internal.admin.AlertListener, - org.apache.geode.distributed.internal.InternalDistributedSystem.DisconnectListener { +public class AdminDistributedSystemImpl implements org.apache.geode.admin.AdminDistributedSystem, + org.apache.geode.internal.admin.JoinLeaveListener, + org.apache.geode.internal.admin.AlertListener, + org.apache.geode.distributed.internal.InternalDistributedSystem.DisconnectListener { private static final Logger logger = LogService.getLogger(); - + /** String identity of this distributed system */ private String id; - + /** Latest alert broadcast by any system members */ private Alert latestAlert; - + // ------------------------------------------------------------------------- /** Internal admin agent to delegate low-level work to */ @@ -80,7 +77,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, /** Set of non-Manager members in this system */ private final Set applicationSet = new HashSet(); - + /** Set of DistributionLocators for this system */ private final Set locatorSet = new HashSet(); @@ -89,70 +86,69 @@ implements org.apache.geode.admin.AdminDistributedSystem, /** Configuration defining this distributed system */ private final DistributedSystemConfigImpl config; - + /** Controller for starting and stopping managed entities */ private ManagedEntityController controller; - + /** Log file collator for gathering and merging system member logs */ private LogCollator logCollator = new LogCollator(); - - /** The level above which alerts will be delivered to the alert - * listeners */ + + /** + * The level above which alerts will be delivered to the alert listeners + */ private AlertLevel alertLevel = AlertLevel.WARNING; /** The alert listeners registered on this distributed system. */ private volatile Set alertListeners = Collections.emptySet(); private final Object alertLock = new Object(); - + private LogWriterAppender logWriterAppender; - + private InternalLogWriter logWriter; - + /** The membership listeners registered on this distributed system */ private volatile Set membershipListeners = Collections.EMPTY_SET; private final Object membershipLock = new Object(); - + /* The region listeners registered on this distributed system */ - //for feature requests #32887 + // for feature requests #32887 private volatile List cacheListeners = Collections.EMPTY_LIST; private final Object cacheListLock = new Object(); - - /** - * reference to AdminDistributedSystemImpl instance - * for feature requests #32887. + + /** + * reference to AdminDistributedSystemImpl instance for feature requests #32887. *

* Guarded by {@link #CONNECTION_SYNC}. *

- * TODO: reimplement this change and SystemMemberCacheEventProcessor to avoid - * using this static. SystemMemberCacheEvents should only be sent to Admin - * VMs that express interest. + * TODO: reimplement this change and SystemMemberCacheEventProcessor to avoid using this static. + * SystemMemberCacheEvents should only be sent to Admin VMs that express interest. *

- * This is volatile to allow SystemFailure to deliver fatal poison-pill - * to thisAdminDS without waiting on synchronization. + * This is volatile to allow SystemFailure to deliver fatal poison-pill to thisAdminDS without + * waiting on synchronization. * * @guarded.By CONNECTION_SYNC */ private static volatile AdminDistributedSystemImpl thisAdminDS; /** - * Provides synchronization for {@link #connect()} and {@link #disconnect()}. - * {@link #thisAdminDS} is also now protected by CONNECTION_SYNC and has its - * lifecycle properly tied to connect/disconnect. + * Provides synchronization for {@link #connect()} and {@link #disconnect()}. {@link #thisAdminDS} + * is also now protected by CONNECTION_SYNC and has its lifecycle properly tied to + * connect/disconnect. */ private static final Object CONNECTION_SYNC = new Object(); - - + + // ------------------------------------------------------------------------- - // Constructor(s) + // Constructor(s) // ------------------------------------------------------------------------- - - /** + + /** * Constructs new DistributedSystemImpl with the given configuration. * - * @param config configuration defining this distributed system + * @param config configuration defining this distributed system */ public AdminDistributedSystemImpl(DistributedSystemConfigImpl config) { - + // init from config... this.config = config; @@ -160,24 +156,27 @@ implements org.apache.geode.admin.AdminDistributedSystem, if (systemId != null && systemId.length() > 0) { this.id = systemId; - } if (this.getLocators() != null && this.getLocators().length() > 0) { + } + if (this.getLocators() != null && this.getLocators().length() > 0) { this.id = this.getLocators(); } else { - this.id = new StringBuffer(this.getMcastAddress()).append("[").append( - this.getMcastPort()).append("]").toString(); + this.id = new StringBuffer(this.getMcastAddress()).append("[").append(this.getMcastPort()) + .append("]").toString(); } // LOG: create LogWriterAppender unless one already exists - this.logWriterAppender = LogWriterAppenders.getOrCreateAppender(LogWriterAppenders.Identifier.MAIN, false, this.config.createLogConfig(), false); - + this.logWriterAppender = LogWriterAppenders.getOrCreateAppender( + LogWriterAppenders.Identifier.MAIN, false, this.config.createLogConfig(), false); + // LOG: look in DistributedSystemConfigImpl for existing LogWriter to use InternalLogWriter existingLogWriter = this.config.getInternalLogWriter(); if (existingLogWriter != null) { this.logWriter = existingLogWriter; - } else { + } else { // LOG: create LogWriterLogger - this.logWriter = LogWriterFactory.createLogWriterLogger(false, false, this.config.createLogConfig(), false); + this.logWriter = LogWriterFactory.createLogWriterLogger(false, false, + this.config.createLogConfig(), false); if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) { // LOG: changed statement from config to info this.logWriter.info(Banner.getString(null)); @@ -187,24 +186,23 @@ implements org.apache.geode.admin.AdminDistributedSystem, // Set this log writer in DistributedSystemConfigImpl this.config.setInternalLogWriter(this.logWriter); } - + // set up other details that depend on config attrs... this.controller = ManagedEntityControllerFactory.createManagedEntityController(this); initializeDistributionLocators(); initializeCacheServers(); } - + // ------------------------------------------------------------------------- - // Initialization + // Initialization // ------------------------------------------------------------------------- - + /** * Creates DistributionLocator instances for every locator entry in the * {@link org.apache.geode.admin.DistributedSystemConfig} */ private void initializeDistributionLocators() { - DistributionLocatorConfig[] configs = - this.config.getDistributionLocatorConfigs(); + DistributionLocatorConfig[] configs = this.config.getDistributionLocatorConfigs(); if (configs.length == 0) { // No work to do return; @@ -213,39 +211,35 @@ implements org.apache.geode.admin.AdminDistributedSystem, for (int i = 0; i < configs.length; i++) { // the Locator impl may vary in this class from the config... DistributionLocatorConfig conf = configs[i]; - DistributionLocator locator = - createDistributionLocatorImpl(conf); + DistributionLocator locator = createDistributionLocatorImpl(conf); this.locatorSet.add(new FutureResult(locator)); } // update locators string... setLocators(parseLocatorSet()); } - + /** - * Creates CacheServer instances for every cache server - * entry in the {@link - * org.apache.geode.admin.DistributedSystemConfig} + * Creates CacheServer instances for every cache server entry in the + * {@link org.apache.geode.admin.DistributedSystemConfig} */ private void initializeCacheServers() { - CacheServerConfig[] cacheServerConfigs = - this.config.getCacheServerConfigs(); + CacheServerConfig[] cacheServerConfigs = this.config.getCacheServerConfigs(); for (int i = 0; i < cacheServerConfigs.length; i++) { try { CacheServerConfig conf = cacheServerConfigs[i]; - CacheServerConfigImpl copy = - new CacheServerConfigImpl(conf); + CacheServerConfigImpl copy = new CacheServerConfigImpl(conf); this.cacheServerSet.add(new FutureResult(createCacheServer(copy))); } catch (java.lang.Exception e) { logger.warn(e.getMessage(), e); continue; } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); - // If this ever returns, rethrow the error. We're poisoned + // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (java.lang.Error e) { // Whenever you catch Error or Throwable, you must also - // catch VirtualMachineError (see above). However, there is + // catch VirtualMachineError (see above). However, there is // _still_ a possibility that you are dealing with a cascading // error condition, so you also need to check to see if the JVM // is still usable: @@ -259,23 +253,24 @@ implements org.apache.geode.admin.AdminDistributedSystem, /** * Checks to make sure that {@link #connect()} has been called. * - * @throws IllegalStateException - * If {@link #connect()} has not been called. + * @throws IllegalStateException If {@link #connect()} has not been called. */ private void checkConnectCalled() { if (this.gfManagerAgent == null) { - throw new IllegalStateException(LocalizedStrings.AdminDistributedSystemImpl_CONNECT_HAS_NOT_BEEN_INVOKED_ON_THIS_ADMINDISTRIBUTEDSYSTEM.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.AdminDistributedSystemImpl_CONNECT_HAS_NOT_BEEN_INVOKED_ON_THIS_ADMINDISTRIBUTEDSYSTEM + .toLocalizedString()); } } // ------------------------------------------------------------------------- - // Attributes of this DistributedSystem + // Attributes of this DistributedSystem // ------------------------------------------------------------------------- - + public GfManagerAgent getGfManagerAgent() { return this.gfManagerAgent; } - + public boolean isConnected() { return this.gfManagerAgent != null && this.gfManagerAgent.isConnected(); } @@ -283,11 +278,11 @@ implements org.apache.geode.admin.AdminDistributedSystem, public String getId() { return this.id; } - + public String getName() { String name = this.config.getSystemName(); if (name != null && name.length() > 0) { - return name; + return name; } else { return getId(); @@ -334,7 +329,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, return this.alertListeners.size(); } } - + public void removeAlertListener(AlertListener listener) { synchronized (this.alertLock) { Set oldListeners = this.alertListeners; @@ -377,11 +372,11 @@ implements org.apache.geode.admin.AdminDistributedSystem, public int getMcastPort() { return this.config.getMcastPort(); } - + public boolean getDisableTcp() { return this.config.getDisableTcp(); } - + public boolean getDisableAutoReconnect() { return this.config.getDisableAutoReconnect(); } @@ -389,20 +384,20 @@ implements org.apache.geode.admin.AdminDistributedSystem, public String getLocators() { return this.config.getLocators(); } - + protected void setLocators(String locators) { this.config.setLocators(locators); } - + public String getMembershipPortRange() { return this.getConfig().getMembershipPortRange(); } - + /** get the direct-channel port to use, or zero if not set */ public int getTcpPort() { return this.getConfig().getTcpPort(); } - + public void setTcpPort(int port) { this.getConfig().setTcpPort(port); } @@ -414,39 +409,40 @@ implements org.apache.geode.admin.AdminDistributedSystem, public DistributedSystemConfig getConfig() { return this.config; } - + /** * Returns true if any members of this system are currently running. */ public boolean isRunning() { - if (this.gfManagerAgent == null) return false; + if (this.gfManagerAgent == null) + return false; // is there a better way?? // this.gfManagerAgent.isConnected() ... this.gfManagerAgent.isListening() - - if (isAnyMemberRunning()) return true; + + if (isAnyMemberRunning()) + return true; return false; } - + /** Returns true if this system can use multicast for communications */ public boolean isMcastEnabled() { - return this.getMcastPort() > 0 ; + return this.getMcastPort() > 0; } - + ManagedEntityController getEntityController() { return this.controller; } - - static private final String TIMEOUT_MS_NAME - = "AdminDistributedSystemImpl.TIMEOUT_MS"; + + static private final String TIMEOUT_MS_NAME = "AdminDistributedSystemImpl.TIMEOUT_MS"; static private final int TIMEOUT_MS_DEFAULT = 60000; // 30000 -- see bug36470 - static private final int TIMEOUT_MS - = Integer.getInteger(TIMEOUT_MS_NAME, TIMEOUT_MS_DEFAULT).intValue(); - + static private final int TIMEOUT_MS = + Integer.getInteger(TIMEOUT_MS_NAME, TIMEOUT_MS_DEFAULT).intValue(); + // ------------------------------------------------------------------------- - // Operations of this DistributedSystem + // Operations of this DistributedSystem // ------------------------------------------------------------------------- - + /** * Starts all managed entities in this system. */ @@ -459,12 +455,17 @@ implements org.apache.geode.admin.AdminDistributedSystem, for (int i = 0; i < locs.length; i++) { try { if (!locs[i].waitToStart(TIMEOUT_MS)) { - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_START_AFTER_1_MS.toLocalizedString(new Object[] {locs[i], Integer.valueOf(TIMEOUT_MS)})); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_START_AFTER_1_MS + .toLocalizedString(new Object[] {locs[i], Integer.valueOf(TIMEOUT_MS)})); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_START.toLocalizedString(locs[i]), ex); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_START + .toLocalizedString(locs[i]), + ex); } } @@ -475,23 +476,28 @@ implements org.apache.geode.admin.AdminDistributedSystem, for (int i = 0; i < servers.length; i++) { try { if (!servers[i].waitToStart(TIMEOUT_MS)) { - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_START_AFTER_1_MS.toLocalizedString(new Object[] {servers[i], Integer.valueOf(TIMEOUT_MS)})); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_START_AFTER_1_MS + .toLocalizedString(new Object[] {servers[i], Integer.valueOf(TIMEOUT_MS)})); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_START.toLocalizedString(servers[i]), ex); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_START + .toLocalizedString(servers[i]), + ex); } } } - + /** * Stops all GemFire managers that are members of this system. */ public void stop() throws AdminException { // Stop cache server before GemFire managers because the cache // server might host a cache proxy that is dependent on the - // manager. See bug 32569. + // manager. See bug 32569. // Wait for each managed entity to stop (see bug 32569) long timeout = 30; @@ -503,12 +509,17 @@ implements org.apache.geode.admin.AdminDistributedSystem, for (int i = 0; i < servers.length; i++) { try { if (!servers[i].waitToStop(timeout * 1000)) { - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_STOP_AFTER_1_SECONDS.toLocalizedString(new Object[] {servers[i], Long.valueOf(timeout)})); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_STOP_AFTER_1_SECONDS + .toLocalizedString(new Object[] {servers[i], Long.valueOf(timeout)})); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_STOP.toLocalizedString(servers[i]), ex); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_STOP + .toLocalizedString(servers[i]), + ex); } } @@ -519,24 +530,29 @@ implements org.apache.geode.admin.AdminDistributedSystem, for (int i = 0; i < locs.length; i++) { try { if (!locs[i].waitToStop(timeout * 1000)) { - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_STOP_AFTER_1_SECONDS.toLocalizedString(new Object[] {locs[i], Long.valueOf(timeout)})); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_0_DID_NOT_STOP_AFTER_1_SECONDS + .toLocalizedString(new Object[] {locs[i], Long.valueOf(timeout)})); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - throw new AdminException(LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_STOP.toLocalizedString(locs[i]), ex); + throw new AdminException( + LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED_WHILE_WAITING_FOR_0_TO_STOP + .toLocalizedString(locs[i]), + ex); } } } - + /** Display merged system member logs */ public String displayMergedLogs() { return this.logCollator.collateLogs(this.gfManagerAgent); } - /** - * Returns the license for this GemFire product; else null if unable to - * retrieve license information + /** + * Returns the license for this GemFire product; else null if unable to retrieve license + * information * * @return license for this GemFire product */ @@ -550,38 +566,28 @@ implements org.apache.geode.admin.AdminDistributedSystem, } /** - * Sets the distribution-related portion of the given managed entity's - * configuration so that the entity is part of this distributed system. + * Sets the distribution-related portion of the given managed entity's configuration so that the + * entity is part of this distributed system. * - * @throws AdminException - * TODO-javadocs + * @throws AdminException TODO-javadocs */ - private void setDistributionParameters(SystemMember member) - throws AdminException { + private void setDistributionParameters(SystemMember member) throws AdminException { Assert.assertTrue(member instanceof ManagedSystemMemberImpl); // set some config parms to match this system... ConfigurationParameter[] configParms = new ConfigurationParameter[] { - new ConfigurationParameterImpl( - MCAST_PORT, - Integer.valueOf(this.config.getMcastPort())), - new ConfigurationParameterImpl( - LOCATORS, - this.config.getLocators()), - new ConfigurationParameterImpl( - MCAST_ADDRESS, + new ConfigurationParameterImpl(MCAST_PORT, Integer.valueOf(this.config.getMcastPort())), + new ConfigurationParameterImpl(LOCATORS, this.config.getLocators()), + new ConfigurationParameterImpl(MCAST_ADDRESS, InetAddressUtil.toInetAddress(this.config.getMcastAddress())), - new ConfigurationParameterImpl( - DISABLE_TCP, - Boolean.valueOf(this.config.getDisableTcp()) ), - }; + new ConfigurationParameterImpl(DISABLE_TCP, Boolean.valueOf(this.config.getDisableTcp())),}; member.setConfiguration(configParms); } /** - * Handles an ExecutionException by examining its cause - * and throwing an appropriate runtime exception. + * Handles an ExecutionException by examining its cause and throwing an appropriate + * runtime exception. */ private static void handle(ExecutionException ex) { Throwable cause = ex.getCause(); @@ -592,16 +598,21 @@ implements org.apache.geode.admin.AdminDistributedSystem, return; } if (cause instanceof CancelException) { // bug 37285 - throw new FutureCancelledException(LocalizedStrings.AdminDistributedSystemImpl_FUTURE_CANCELLED_DUE_TO_SHUTDOWN.toLocalizedString(), ex); + throw new FutureCancelledException( + LocalizedStrings.AdminDistributedSystemImpl_FUTURE_CANCELLED_DUE_TO_SHUTDOWN + .toLocalizedString(), + ex); } // Don't just throw the cause because the stack trace can be - // misleading. For instance, the cause might have occurred in a - // different thread. In addition to the cause, we also want to + // misleading. For instance, the cause might have occurred in a + // different thread. In addition to the cause, we also want to // know which code was waiting for the Future. - throw new RuntimeAdminException(LocalizedStrings.AdminDistributedSystemImpl_WHILE_WAITING_FOR_FUTURE.toLocalizedString(), ex); + throw new RuntimeAdminException( + LocalizedStrings.AdminDistributedSystemImpl_WHILE_WAITING_FOR_FUTURE.toLocalizedString(), + ex); } - + protected void checkCancellation() { DM dm = this.getDistributionManager(); // TODO does dm == null mean we're dead? @@ -609,41 +620,35 @@ implements org.apache.geode.admin.AdminDistributedSystem, dm.getCancelCriterion().checkCancelInProgress(null); } } + /** - * Returns a list of manageable SystemMember instances for each - * member of this distributed system. + * Returns a list of manageable SystemMember instances for each member of this distributed system. * * @return array of system members for each non-manager member */ - public SystemMember[] getSystemMemberApplications() - throws org.apache.geode.admin.AdminException { - synchronized(this.applicationSet) { + public SystemMember[] getSystemMemberApplications() throws org.apache.geode.admin.AdminException { + synchronized (this.applicationSet) { Collection coll = new ArrayList(this.applicationSet.size()); - APPS: for (Iterator iter = this.applicationSet.iterator(); - iter.hasNext(); ) { + APPS: for (Iterator iter = this.applicationSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); -// this.logger.info("DEBUG: getSystemMemberApplications: " + future); + // this.logger.info("DEBUG: getSystemMemberApplications: " + future); for (;;) { checkCancellation(); boolean interrupted = Thread.interrupted(); try { coll.add(future.get()); break; - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { -// this.logger.info("DEBUG: cancelled: " + future, ex); + } catch (CancellationException ex) { + // this.logger.info("DEBUG: cancelled: " + future, ex); continue APPS; - } - catch (ExecutionException ex) { -// this.logger.info("DEBUG: executed: " + future); + } catch (ExecutionException ex) { + // this.logger.info("DEBUG: executed: " + future); handle(ex); continue APPS; - } - finally { + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -667,7 +672,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, } return this.latestAlert.toString(); } - + /** * Connects to the currently configured system. */ @@ -676,59 +681,62 @@ implements org.apache.geode.admin.AdminDistributedSystem, } /** - * Connects to the currently configured system. This method is - * public for internal use only (testing, for example). + * Connects to the currently configured system. This method is public for internal use only + * (testing, for example). * *

* - * See {@link - * org.apache.geode.distributed.DistributedSystem#connect} for a - * list of exceptions that may be thrown. + * See {@link org.apache.geode.distributed.DistributedSystem#connect} for a list of exceptions + * that may be thrown. * * @param logWriter the InternalLogWriter to use for any logging */ public void connect(InternalLogWriter logWriter) { synchronized (CONNECTION_SYNC) { - //Check if the gfManagerAgent is NOT null. - //If it is already listening, then just return since the connection is already established OR in process. - //Otherwise cleanup the state of AdminDistributedSystemImpl. This needs to happen automatically. - if(this.gfManagerAgent != null) { - if(this.gfManagerAgent.isListening()) { - if (logger.isDebugEnabled()) { - logger.debug("The RemoteGfManagerAgent is already listening for this AdminDistributedSystem."); - } - return; - } - this.disconnect(); + // Check if the gfManagerAgent is NOT null. + // If it is already listening, then just return since the connection is already established OR + // in process. + // Otherwise cleanup the state of AdminDistributedSystemImpl. This needs to happen + // automatically. + if (this.gfManagerAgent != null) { + if (this.gfManagerAgent.isListening()) { + if (logger.isDebugEnabled()) { + logger.debug( + "The RemoteGfManagerAgent is already listening for this AdminDistributedSystem."); + } + return; + } + this.disconnect(); } - + if (thisAdminDS != null) { // TODO: beef up toString and add thisAdminDS - throw new IllegalStateException(LocalizedStrings.AdminDistributedSystemImpl_ONLY_ONE_ADMINDISTRIBUTEDSYSTEM_CONNECTION_CAN_BE_MADE_AT_ONCE.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.AdminDistributedSystemImpl_ONLY_ONE_ADMINDISTRIBUTEDSYSTEM_CONNECTION_CAN_BE_MADE_AT_ONCE + .toLocalizedString()); } - - thisAdminDS = this; //added for feature requests #32887 - + + thisAdminDS = this; // added for feature requests #32887 + if (this.getLocators().length() == 0) { - this.id = - this.getMcastAddress() + "[" + this.getMcastPort() + "]"; - + this.id = this.getMcastAddress() + "[" + this.getMcastPort() + "]"; + } else { this.id = this.getLocators(); } - + if (this.config instanceof DistributedSystemConfigImpl) { ((DistributedSystemConfigImpl) this.config).validate(); ((DistributedSystemConfigImpl) this.config).setDistributedSystem(this); } - - // LOG: passes the AdminDistributedSystemImpl LogWriterLogger into GfManagerAgentConfig for RemoteGfManagerAgent - GfManagerAgent agent = - GfManagerAgentFactory.getManagerAgent(buildAgentConfig(logWriter)); + + // LOG: passes the AdminDistributedSystemImpl LogWriterLogger into GfManagerAgentConfig for + // RemoteGfManagerAgent + GfManagerAgent agent = GfManagerAgentFactory.getManagerAgent(buildAgentConfig(logWriter)); this.gfManagerAgent = agent; - + // sync to prevent bug 33341 Admin API can double-represent system members - synchronized(this.membershipListenerLock) { - // build the list of applications... + synchronized (this.membershipListenerLock) { + // build the list of applications... ApplicationVM[] apps = this.gfManagerAgent.listApplications(); for (int i = 0; i < apps.length; i++) { try { @@ -742,8 +750,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, // Build admin objects for all locators (see bug 31959) String locators = this.getLocators(); StringTokenizer st = new StringTokenizer(locators, ","); - NEXT: - while(st.hasMoreTokens()) { + NEXT: while (st.hasMoreTokens()) { String locator = st.nextToken(); int first = locator.indexOf("["); int last = locator.indexOf("]"); @@ -753,9 +760,9 @@ implements org.apache.geode.admin.AdminDistributedSystem, colidx = host.lastIndexOf(':'); } String bindAddr = null; - if (colidx > 0 && colidx < (host.length()-1)) { + if (colidx > 0 && colidx < (host.length() - 1)) { String orig = host; - bindAddr = host.substring(colidx+1, host.length()); + bindAddr = host.substring(colidx + 1, host.length()); host = host.substring(0, colidx); // if the host contains a colon and there's no '@', we probably // parsed an ipv6 address incorrectly - try again @@ -763,20 +770,17 @@ implements org.apache.geode.admin.AdminDistributedSystem, int bindidx = orig.lastIndexOf('@'); if (bindidx >= 0) { host = orig.substring(0, bindidx); - bindAddr = orig.substring(bindidx+1); - } - else { + bindAddr = orig.substring(bindidx + 1); + } else { host = orig; bindAddr = null; } } } - int port = Integer.parseInt(locator.substring(first+1, last)); + int port = Integer.parseInt(locator.substring(first + 1, last)); synchronized (this.locatorSet) { - LOCATORS: - for (Iterator iter = this.locatorSet.iterator(); - iter.hasNext(); ) { + LOCATORS: for (Iterator iter = this.locatorSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); DistributionLocatorImpl impl = null; for (;;) { @@ -785,19 +789,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { impl = (DistributionLocatorImpl) future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue LOCATORS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); continue LOCATORS; - } - finally { + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -807,8 +807,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, DistributionLocatorConfig conf = impl.getConfig(); InetAddress host1 = InetAddressUtil.toInetAddress(host); - InetAddress host2 = - InetAddressUtil.toInetAddress(conf.getHost()); + InetAddress host2 = InetAddressUtil.toInetAddress(conf.getHost()); if (port == conf.getPort() && host1.equals(host2)) { // Already have an admin object for this locator continue NEXT; @@ -817,18 +816,16 @@ implements org.apache.geode.admin.AdminDistributedSystem, } // None of the existing locators matches the locator in the - // string. Contact the locator to get information and create + // string. Contact the locator to get information and create // an admin object for it. InetAddress bindAddress = null; if (bindAddr != null) { bindAddress = InetAddressUtil.toInetAddress(bindAddr); } DistributionLocatorConfig conf = - DistributionLocatorConfigImpl.createConfigFor(host, port, - bindAddress); + DistributionLocatorConfigImpl.createConfigFor(host, port, bindAddress); if (conf != null) { - DistributionLocator impl = - createDistributionLocatorImpl(conf); + DistributionLocator impl = createDistributionLocatorImpl(conf); synchronized (this.locatorSet) { this.locatorSet.add(new FutureResult(impl)); } @@ -836,16 +833,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, } } } - + /** - * Polls to determine whether or not the connection to the - * distributed system has been made. + * Polls to determine whether or not the connection to the distributed system has been made. */ - public boolean waitToBeConnected(long timeout) - throws InterruptedException { + public boolean waitToBeConnected(long timeout) throws InterruptedException { + + if (Thread.interrupted()) + throw new InterruptedException(); - if (Thread.interrupted()) throw new InterruptedException(); - checkConnectCalled(); long start = System.currentTimeMillis(); @@ -861,37 +857,37 @@ implements org.apache.geode.admin.AdminDistributedSystem, return this.isConnected(); } - /** + /** * Closes all connections and resources to the connected distributed system. * * @see org.apache.geode.distributed.DistributedSystem#disconnect() */ public void disconnect() { synchronized (CONNECTION_SYNC) { -// if (!isConnected()) { -// throw new IllegalStateException(this + " is not connected"); -// } -// Assert.assertTrue(thisAdminDS == this); + // if (!isConnected()) { + // throw new IllegalStateException(this + " is not connected"); + // } + // Assert.assertTrue(thisAdminDS == this); if (this.logWriterAppender != null) { LogWriterAppenders.stop(LogWriterAppenders.Identifier.MAIN); } try { - if (thisAdminDS == this) { - thisAdminDS = null; - } - if (this.gfManagerAgent != null && this.gfManagerAgent.isListening()){ - synchronized (this) { - if (this.health != null) { - this.health.close(); + if (thisAdminDS == this) { + thisAdminDS = null; + } + if (this.gfManagerAgent != null && this.gfManagerAgent.isListening()) { + synchronized (this) { + if (this.health != null) { + this.health.close(); + } } + this.gfManagerAgent.removeJoinLeaveListener(this); + this.gfManagerAgent.disconnect(); + } + this.gfManagerAgent = null; + if (this.config instanceof DistributedSystemConfigImpl) { + ((DistributedSystemConfigImpl) this.config).setDistributedSystem(null); } - this.gfManagerAgent.removeJoinLeaveListener(this); - this.gfManagerAgent.disconnect(); - } - this.gfManagerAgent = null; - if (this.config instanceof DistributedSystemConfigImpl) { - ((DistributedSystemConfigImpl) this.config).setDistributedSystem(null); - } } finally { if (logWriterAppender != null) { LogWriterAppenders.destroy(LogWriterAppenders.Identifier.MAIN); @@ -899,38 +895,35 @@ implements org.apache.geode.admin.AdminDistributedSystem, } } } - + /** - * Returns the DistributionManager this implementation is using to - * connect to the distributed system. + * Returns the DistributionManager this implementation is using to connect to the distributed + * system. */ public DM getDistributionManager() { if (this.gfManagerAgent == null) { return null; } return this.gfManagerAgent.getDM(); - + } - + /** - * Returns the internal admin API's agent used for administering - * this AdminDistributedSystem. + * Returns the internal admin API's agent used for administering this + * AdminDistributedSystem. * * @since GemFire 4.0 */ public GfManagerAgent getAdminAgent() { return this.gfManagerAgent; } - + /** - * Adds a new, unstarted DistributionLocator to this - * distributed system. + * Adds a new, unstarted DistributionLocator to this distributed system. */ public DistributionLocator addDistributionLocator() { - DistributionLocatorConfig conf = - new DistributionLocatorConfigImpl(); - DistributionLocator locator = - createDistributionLocatorImpl(conf); + DistributionLocatorConfig conf = new DistributionLocatorConfigImpl(); + DistributionLocator locator = createDistributionLocatorImpl(conf); synchronized (this.locatorSet) { this.locatorSet.add(new FutureResult(locator)); } @@ -939,12 +932,11 @@ implements org.apache.geode.admin.AdminDistributedSystem, setLocators(parseLocatorSet()); return locator; } - + public DistributionLocator[] getDistributionLocators() { - synchronized(this.locatorSet) { + synchronized (this.locatorSet) { Collection coll = new ArrayList(this.locatorSet.size()); - LOCATORS: for (Iterator iter = this.locatorSet.iterator(); - iter.hasNext();) { + LOCATORS: for (Iterator iter = this.locatorSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); for (;;) { checkCancellation(); @@ -952,19 +944,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { coll.add(future.get()); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue LOCATORS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); continue LOCATORS; - } - finally { + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -972,16 +960,14 @@ implements org.apache.geode.admin.AdminDistributedSystem, } // for } - DistributionLocator[] array = - new DistributionLocator[coll.size()]; + DistributionLocator[] array = new DistributionLocator[coll.size()]; coll.toArray(array); return array; } } - + /** - * Updates the locator string that is used to discover members of - * the distributed system. + * Updates the locator string that is used to discover members of the distributed system. * * @see #getLocators */ @@ -1000,19 +986,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { locator = (DistributionLocator) future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue LOCATORS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); continue LOCATORS; - } - finally { + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -1027,192 +1009,183 @@ implements org.apache.geode.admin.AdminDistributedSystem, } return sb.toString(); } - + // ------------------------------------------------------------------------- - // Listener callback methods + // Listener callback methods // ------------------------------------------------------------------------- - + /** sync to prevent bug 33341 Admin API can double-represent system members */ private final Object membershipListenerLock = new Object(); - + // --------- org.apache.geode.internal.admin.JoinLeaveListener --------- - /** + /** * Listener callback for when a member has joined this DistributedSystem. *

- * React by adding the SystemMember to this system's - * internal lists, if they are not already there. Notice that we - * add a {@link Future} into the list so that the admin object is - * not initialized while locks are held. + * React by adding the SystemMember to this system's internal lists, if they are not already + * there. Notice that we add a {@link Future} into the list so that the admin object is not + * initialized while locks are held. * - * @param source the distributed system that fired nodeJoined - * @param vm the VM that joined + * @param source the distributed system that fired nodeJoined + * @param vm the VM that joined * @see org.apache.geode.internal.admin.JoinLeaveListener#nodeJoined */ public void nodeJoined(GfManagerAgent source, final GemFireVM vm) { // sync to prevent bug 33341 Admin API can double-represent system members - synchronized(this.membershipListenerLock) { -// this.logger.info("DEBUG: nodeJoined: " + vm.getId(), new RuntimeException("STACK")); + synchronized (this.membershipListenerLock) { + // this.logger.info("DEBUG: nodeJoined: " + vm.getId(), new RuntimeException("STACK")); - // does it already exist? - SystemMember member = findSystemMember(vm); - - // if not then create it... - if (member == null) { -// this.logger.info("DEBUG: no existing member: " + vm.getId()); - FutureTask future = null; - //try { + // does it already exist? + SystemMember member = findSystemMember(vm); + + // if not then create it... + if (member == null) { + // this.logger.info("DEBUG: no existing member: " + vm.getId()); + FutureTask future = null; + // try { if (vm instanceof ApplicationVM) { final ApplicationVM app = (ApplicationVM) vm; if (app.isDedicatedCacheServer()) { synchronized (this.cacheServerSet) { future = new AdminFutureTask(vm.getId(), new Callable() { - public Object call() throws Exception { - logger.info(LogMarker.DM, LocalizedMessage.create(LocalizedStrings.AdminDistributedSystemImpl_ADDING_NEW_CACHESERVER_FOR__0, vm)); - return createCacheServer(app); - } - }); - + public Object call() throws Exception { + logger.info(LogMarker.DM, + LocalizedMessage.create( + LocalizedStrings.AdminDistributedSystemImpl_ADDING_NEW_CACHESERVER_FOR__0, + vm)); + return createCacheServer(app); + } + }); + this.cacheServerSet.add(future); } } else { synchronized (this.applicationSet) { future = new AdminFutureTask(vm.getId(), new Callable() { - public Object call() throws Exception { - logger.info(LogMarker.DM, LocalizedMessage.create(LocalizedStrings.AdminDistributedSystemImpl_ADDING_NEW_APPLICATION_FOR__0, vm)); - return createSystemMember(app); - } - }); + public Object call() throws Exception { + logger.info(LogMarker.DM, + LocalizedMessage.create( + LocalizedStrings.AdminDistributedSystemImpl_ADDING_NEW_APPLICATION_FOR__0, + vm)); + return createSystemMember(app); + } + }); this.applicationSet.add(future); } } } else { - Assert.assertTrue(false, "Unknown GemFireVM type: " + - vm.getClass().getName()); - } - -// } catch (AdminException ex) { -// String s = "Could not create a SystemMember for " + vm; -// this.logger.warning(s, ex); -// } - - // Wait for the SystemMember to be created. We want to do this - // outside of the "set" locks. - future.run(); - for (;;) { - checkCancellation(); - boolean interrupted = Thread.interrupted(); - try { - member = (SystemMember) future.get(); - break; // success - } - catch (InterruptedException ex) { - interrupted = true; - continue; // keep trying - } - catch (CancellationException ex) { -// this.logger.info("DEBUG: run cancelled: " + future, ex); - return; - } - catch (ExecutionException ex) { -// this.logger.info("DEBUG: run executed: " + future, ex); - handle(ex); - return; + Assert.assertTrue(false, "Unknown GemFireVM type: " + vm.getClass().getName()); } - finally { - if (interrupted) { - Thread.currentThread().interrupt(); + + // } catch (AdminException ex) { + // String s = "Could not create a SystemMember for " + vm; + // this.logger.warning(s, ex); + // } + + // Wait for the SystemMember to be created. We want to do this + // outside of the "set" locks. + future.run(); + for (;;) { + checkCancellation(); + boolean interrupted = Thread.interrupted(); + try { + member = (SystemMember) future.get(); + break; // success + } catch (InterruptedException ex) { + interrupted = true; + continue; // keep trying + } catch (CancellationException ex) { + // this.logger.info("DEBUG: run cancelled: " + future, ex); + return; + } catch (ExecutionException ex) { + // this.logger.info("DEBUG: run executed: " + future, ex); + handle(ex); + return; + } finally { + if (interrupted) { + Thread.currentThread().interrupt(); + } } - } - } // for + } // for - Assert.assertTrue(member != null); + Assert.assertTrue(member != null); - // moved this up into the if that creates a new member to fix bug 34517 - SystemMembershipEvent event = new SystemMembershipEventImpl(member.getDistributedMember()); - for (Iterator iter = this.membershipListeners.iterator(); - iter.hasNext(); ) { - SystemMembershipListener listener = - (SystemMembershipListener) iter.next(); - listener.memberJoined(event); + // moved this up into the if that creates a new member to fix bug 34517 + SystemMembershipEvent event = new SystemMembershipEventImpl(member.getDistributedMember()); + for (Iterator iter = this.membershipListeners.iterator(); iter.hasNext();) { + SystemMembershipListener listener = (SystemMembershipListener) iter.next(); + listener.memberJoined(event); + } + // } else { + // this.logger.info("DEBUG: found existing member: " + member); } -// } else { -// this.logger.info("DEBUG: found existing member: " + member); - } } } - - /** + + /** * Listener callback for when a member of this DistributedSystem has left. *

* Reacts by removing the member. * - * @param source the distributed system that fired nodeCrashed - * @param vm the VM that left + * @param source the distributed system that fired nodeCrashed + * @param vm the VM that left * @see org.apache.geode.internal.admin.JoinLeaveListener#nodeLeft */ public void nodeLeft(GfManagerAgent source, GemFireVM vm) { // sync to prevent bug 33341 Admin API can double-represent system members - synchronized(this.membershipListenerLock) { + synchronized (this.membershipListenerLock) { // member has left... - SystemMember member = - AdminDistributedSystemImpl.this.removeSystemMember(vm.getId()); + SystemMember member = AdminDistributedSystemImpl.this.removeSystemMember(vm.getId()); if (member == null) { return; // reinstated this early-out because removal does not fix 39429 } - + // Can't call member.getId() because it is nulled-out when the // SystemMember is removed. SystemMembershipEvent event = new SystemMembershipEventImpl(vm.getId()); - for (Iterator iter = this.membershipListeners.iterator(); - iter.hasNext(); ) { - SystemMembershipListener listener = - (SystemMembershipListener) iter.next(); + for (Iterator iter = this.membershipListeners.iterator(); iter.hasNext();) { + SystemMembershipListener listener = (SystemMembershipListener) iter.next(); listener.memberLeft(event); } } } - - /** + + /** * Listener callback for when a member of this DistributedSystem has crashed. *

* Reacts by removing the member. * - * @param source the distributed system that fired nodeCrashed + * @param source the distributed system that fired nodeCrashed * @param vm the VM that crashed * @see org.apache.geode.internal.admin.JoinLeaveListener#nodeCrashed */ public void nodeCrashed(GfManagerAgent source, GemFireVM vm) { // sync to prevent bug 33341 Admin API can double-represent system members - synchronized(this.membershipListenerLock) { + synchronized (this.membershipListenerLock) { // member has crashed... - SystemMember member = - AdminDistributedSystemImpl.this.removeSystemMember(vm.getId()); + SystemMember member = AdminDistributedSystemImpl.this.removeSystemMember(vm.getId()); if (member == null) { - // Unknown member crashed. Hmm... + // Unknown member crashed. Hmm... return; } // Can't call member.getId() because it is nulled-out when the // SystemMember is removed. SystemMembershipEvent event = new SystemMembershipEventImpl(vm.getId()); - for (Iterator iter = this.membershipListeners.iterator(); - iter.hasNext(); ) { - SystemMembershipListener listener = - (SystemMembershipListener) iter.next(); + for (Iterator iter = this.membershipListeners.iterator(); iter.hasNext();) { + SystemMembershipListener listener = (SystemMembershipListener) iter.next(); listener.memberCrashed(event); } } } // ----------- org.apache.geode.internal.admin.AlertListener ----------- - /** - * Listener callback for when a SystemMember of this DistributedSystem has - * crashed. + /** + * Listener callback for when a SystemMember of this DistributedSystem has crashed. * - * @param alert the latest alert from the system + * @param alert the latest alert from the system * @see org.apache.geode.internal.admin.AlertListener#alert */ public void alert(org.apache.geode.internal.admin.Alert alert) { @@ -1221,77 +1194,71 @@ implements org.apache.geode.admin.AdminDistributedSystem, } Alert alert2 = new AlertImpl(alert); this.latestAlert = alert2; - for (Iterator iter = this.alertListeners.iterator(); - iter.hasNext(); ) { + for (Iterator iter = this.alertListeners.iterator(); iter.hasNext();) { AlertListener listener = iter.next(); listener.alert(alert2); } } - + public void onDisconnect(InternalDistributedSystem sys) { - logger.debug("Calling AdminDistributedSystemImpl#onDisconnect"); - disconnect(); - logger.debug("Completed AdminDistributedSystemImpl#onDisconnect"); + logger.debug("Calling AdminDistributedSystemImpl#onDisconnect"); + disconnect(); + logger.debug("Completed AdminDistributedSystemImpl#onDisconnect"); } - + // ------------------------------------------------------------------------- - // Template methods overriden from superclass... + // Template methods overriden from superclass... // ------------------------------------------------------------------------- - - protected CacheServer createCacheServer(ApplicationVM member) - throws AdminException { + + protected CacheServer createCacheServer(ApplicationVM member) throws AdminException { return new CacheServerImpl(this, member); } - protected CacheServer createCacheServer(CacheServerConfigImpl conf) - throws AdminException { + protected CacheServer createCacheServer(CacheServerConfigImpl conf) throws AdminException { return new CacheServerImpl(this, conf); } - /** Override createSystemMember by instantiating SystemMemberImpl + /** + * Override createSystemMember by instantiating SystemMemberImpl * - * @throws AdminException TODO-javadocs + * @throws AdminException TODO-javadocs */ protected SystemMember createSystemMember(ApplicationVM app) - throws org.apache.geode.admin.AdminException { + throws org.apache.geode.admin.AdminException { return new SystemMemberImpl(this, app); } /** - * Constructs & returns a SystemMember instance using the corresponding - * InternalDistributedMember object. + * Constructs & returns a SystemMember instance using the corresponding InternalDistributedMember + * object. * - * @param member - * InternalDistributedMember instance for which a SystemMember - * instance is to be constructed. + * @param member InternalDistributedMember instance for which a SystemMember instance is to be + * constructed. * @return constructed SystemMember instance - * @throws org.apache.geode.admin.AdminException - * if construction of SystemMember instance fails + * @throws org.apache.geode.admin.AdminException if construction of SystemMember instance fails * @since GemFire 6.5 */ protected SystemMember createSystemMember(InternalDistributedMember member) - throws org.apache.geode.admin.AdminException { + throws org.apache.geode.admin.AdminException { return new SystemMemberImpl(this, member); } - /** - * Template-method for creating a new - * DistributionLocatorImpl instance. + /** + * Template-method for creating a new DistributionLocatorImpl instance. */ - protected DistributionLocatorImpl - createDistributionLocatorImpl(DistributionLocatorConfig conf) { + protected DistributionLocatorImpl createDistributionLocatorImpl(DistributionLocatorConfig conf) { return new DistributionLocatorImpl(conf, this); } - + // ------------------------------------------------------------------------- - // Non-public implementation methods... TODO: narrow access levels + // Non-public implementation methods... TODO: narrow access levels // ------------------------------------------------------------------------- // TODO: public void connect(...) could stand to have some internals factored out - - /** + + /** * Returns List of Locators including Locators or Multicast. * * @return list of locators or multicast values @@ -1301,9 +1268,8 @@ implements org.apache.geode.admin.AdminDistributedSystem, // assumes host[port] format, delimited by "," List locatorIds = new ArrayList(); if (isMcastEnabled()) { - String mcastId = new StringBuffer( - this.getMcastAddress()).append("[").append( - this.getMcastPort()).append("]").toString(); + String mcastId = new StringBuffer(this.getMcastAddress()).append("[") + .append(this.getMcastPort()).append("]").toString(); locatorIds.add(new DistributionLocatorId(mcastId)); } StringTokenizer st = new StringTokenizer(this.getLocators(), ","); @@ -1313,7 +1279,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, if (logger.isDebugEnabled()) { StringBuffer sb = new StringBuffer("Locator set is: "); - for (Iterator iter = locatorIds.iterator(); iter.hasNext(); ) { + for (Iterator iter = locatorIds.iterator(); iter.hasNext();) { sb.append(iter.next()); sb.append(" "); } @@ -1322,22 +1288,17 @@ implements org.apache.geode.admin.AdminDistributedSystem, return locatorIds; } - + /** - * Returns whether or not a SystemMember corresponds - * to a GemFireVM. + * Returns whether or not a SystemMember corresponds to a GemFireVM. * - * @param examineConfig - * Should we take the configuration of the member into - * consideration? In general, we want to consider the - * configuration when a member starts up. But when we are - * notified that it has shut down, we do not want to examine - * the configuration because that might involve contacting - * the member. Which, of course, cannot be done because it - * has shut down. + * @param examineConfig Should we take the configuration of the member into consideration? In + * general, we want to consider the configuration when a member starts up. But when we are + * notified that it has shut down, we do not want to examine the configuration because that + * might involve contacting the member. Which, of course, cannot be done because it has + * shut down. */ - private boolean isSame(SystemMemberImpl member, GemFireVM vm, - boolean examineConfig) { + private boolean isSame(SystemMemberImpl member, GemFireVM vm, boolean examineConfig) { if (vm.equals(member.getGemFireVM())) { return true; } @@ -1349,16 +1310,14 @@ implements org.apache.geode.admin.AdminDistributedSystem, return true; } - if ((member instanceof ManagedSystemMemberImpl) && - examineConfig) { + if ((member instanceof ManagedSystemMemberImpl) && examineConfig) { // We can't compare information about managers because the - // member might have already gone away. Attempts to send it + // member might have already gone away. Attempts to send it // messages (to get its product directory, for instance) will // time out. - ManagedSystemMemberImpl entity = - (ManagedSystemMemberImpl) member; + ManagedSystemMemberImpl entity = (ManagedSystemMemberImpl) member; // Make sure that the type of the managed entity matches the // type of the internal admin object. @@ -1374,18 +1333,16 @@ implements org.apache.geode.admin.AdminDistributedSystem, } ManagedEntityConfig conf = entity.getEntityConfig(); - InetAddress managedHost = - InetAddressUtil.toInetAddress(conf.getHost()); + InetAddress managedHost = InetAddressUtil.toInetAddress(conf.getHost()); File managedWorkingDir = new File(conf.getWorkingDirectory()); File managedProdDir = new File(conf.getProductDirectory()); - + InetAddress vmHost = vm.getHost(); File vmWorkingDir = vm.getWorkingDirectory(); File vmProdDir = vm.getGemFireDir(); - if (vmHost.equals(managedHost) && - isSameFile(vmWorkingDir, managedWorkingDir) && - isSameFile(vmProdDir, managedProdDir)) { + if (vmHost.equals(managedHost) && isSameFile(vmWorkingDir, managedWorkingDir) + && isSameFile(vmProdDir, managedProdDir)) { return true; } } @@ -1394,8 +1351,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, } /** - * Returns whether or not the names of the two files represent the - * same file. + * Returns whether or not the names of the two files represent the same file. */ private boolean isSameFile(File file1, File file2) { if (file1.equals(file2)) { @@ -1411,102 +1367,91 @@ implements org.apache.geode.admin.AdminDistributedSystem, return true; } -// StringBuffer sb = new StringBuffer(); -// sb.append("File 1: "); -// sb.append(file1); -// sb.append("\nFile 2: "); -// sb.append(file2); -// sb.append("\n Absolute 1: "); -// sb.append(file1.getAbsoluteFile()); -// sb.append("\n Absolute 2: "); -// sb.append(file2.getAbsoluteFile()); -// sb.append("\n Canonical 1: "); -// sb.append(file1.getCanonicalFile()); -// sb.append("\n Canonical 2: "); -// sb.append(file2.getCanonicalFile()); -// logger.info(sb.toString()); + // StringBuffer sb = new StringBuffer(); + // sb.append("File 1: "); + // sb.append(file1); + // sb.append("\nFile 2: "); + // sb.append(file2); + // sb.append("\n Absolute 1: "); + // sb.append(file1.getAbsoluteFile()); + // sb.append("\n Absolute 2: "); + // sb.append(file2.getAbsoluteFile()); + // sb.append("\n Canonical 1: "); + // sb.append(file1.getCanonicalFile()); + // sb.append("\n Canonical 2: "); + // sb.append(file2.getCanonicalFile()); + // logger.info(sb.toString()); } catch (IOException ex) { // oh well... - logger.info(LocalizedMessage.create(LocalizedStrings.AdminDistributedSystemImpl_WHILE_GETTING_CANONICAL_FILE), ex); + logger.info(LocalizedMessage + .create(LocalizedStrings.AdminDistributedSystemImpl_WHILE_GETTING_CANONICAL_FILE), ex); } return false; } /** - * Finds and returns the SystemMember that corresponds - * to the given GemFireVM or null if no - * SystemMember corresponds. + * Finds and returns the SystemMember that corresponds to the given + * GemFireVM or null if no SystemMember corresponds. */ protected SystemMember findSystemMember(GemFireVM vm) { return findSystemMember(vm, true); } /** - * Finds and returns the SystemMember that corresponds to the - * given GemFireVM or null if no Finds and returns - * the SystemMember that corresponds to the given - * GemFireVM or null if no SystemMember - * corresponds. + * Finds and returns the SystemMember that corresponds to the given + * GemFireVM or null if no Finds and returns the + * SystemMember that corresponds to the given GemFireVM or + * null if no SystemMember corresponds. * * - * @param vm - * GemFireVM instance - * @param compareConfig - * Should the members' configurations be compared? true - * when the member has joined, false when the member has - * left Should the members' configurations be compared? - * true when the member has joined, false - * when the member has left. Additionally also used to check if system - * member config is to be synchronized with the VM. + * @param vm GemFireVM instance + * @param compareConfig Should the members' configurations be compared? true when the + * member has joined, false when the member has left Should the members' + * configurations be compared? true when the member has joined, + * false when the member has left. Additionally also used to check if system + * member config is to be synchronized with the VM. */ - protected SystemMember findSystemMember(GemFireVM vm, - boolean compareConfig) { + protected SystemMember findSystemMember(GemFireVM vm, boolean compareConfig) { SystemMemberImpl member = null; - synchronized (this.cacheServerSet) { - SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); - iter.hasNext(); ) { - Future future = (Future) iter.next(); - CacheServerImpl cacheServer = null; - for (;;) { - checkCancellation(); - boolean interrupted = Thread.interrupted(); - try { - cacheServer = (CacheServerImpl) future.get(); - break; // success - } - catch (InterruptedException ex) { - interrupted = true; - continue; // keep trying - } - catch (CancellationException ex) { - continue SERVERS; - } - catch (ExecutionException ex) { - handle(ex); - continue SERVERS; - } - finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } + synchronized (this.cacheServerSet) { + SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); iter.hasNext();) { + Future future = (Future) iter.next(); + CacheServerImpl cacheServer = null; + for (;;) { + checkCancellation(); + boolean interrupted = Thread.interrupted(); + try { + cacheServer = (CacheServerImpl) future.get(); + break; // success + } catch (InterruptedException ex) { + interrupted = true; + continue; // keep trying + } catch (CancellationException ex) { + continue SERVERS; + } catch (ExecutionException ex) { + handle(ex); + continue SERVERS; + } finally { + if (interrupted) { + Thread.currentThread().interrupt(); } - } // for - - if (isSame(cacheServer, vm, compareConfig)) { - member = cacheServer; - break; } - } + } // for + + if (isSame(cacheServer, vm, compareConfig)) { + member = cacheServer; + break; + } } + } if (member == null) { synchronized (this.applicationSet) { - APPS: for (Iterator iter = this.applicationSet.iterator(); - iter.hasNext(); ) { + APPS: for (Iterator iter = this.applicationSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); SystemMemberImpl application = null; for (;;) { @@ -1515,19 +1460,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { application = (SystemMemberImpl) future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue APPS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); continue APPS; - } - finally { + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -1547,48 +1488,47 @@ implements org.apache.geode.admin.AdminDistributedSystem, member.setGemFireVM(vm); } catch (AdminException ex) { - logger.warn(LocalizedMessage.create(LocalizedStrings.AdminDistributedSystem_COULD_NOT_SET_THE_GEMFIRE_VM), ex); + logger.warn(LocalizedMessage + .create(LocalizedStrings.AdminDistributedSystem_COULD_NOT_SET_THE_GEMFIRE_VM), ex); } } return member; } - - /** + + /** * Removes a SystemMember from this system's list of known members. * - * @param systemMember the member to remove + * @param systemMember the member to remove * @return the system member that was removed; null if no match was found */ protected SystemMember removeSystemMember(SystemMember systemMember) { - return removeSystemMember( - ((SystemMemberImpl) systemMember).getInternalId()); - } - - /** - * Removes a SystemMember from this system's list of known members. This - * method is called in response to a member leaving the system. - * TODO: this method is a mess of defns + return removeSystemMember(((SystemMemberImpl) systemMember).getInternalId()); + } + + /** + * Removes a SystemMember from this system's list of known members. This method is called in + * response to a member leaving the system. TODO: this method is a mess of defns * - * @param internalId the unique id that specifies which member to remove + * @param internalId the unique id that specifies which member to remove * @return the system member that was removed; null if no match was found */ protected SystemMember removeSystemMember(InternalDistributedMember internalId) { - if (internalId == null) return null; + if (internalId == null) + return null; -// this.logger.info("DEBUG: removeSystemMember: " + internalId, new RuntimeException("STACK")); + // this.logger.info("DEBUG: removeSystemMember: " + internalId, new RuntimeException("STACK")); boolean found = false; SystemMemberImpl member = null; - synchronized(this.cacheServerSet) { - SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); - iter.hasNext() && !found; ) { + synchronized (this.cacheServerSet) { + SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); iter.hasNext() && !found;) { Future future = (Future) iter.next(); if (future instanceof AdminFutureTask) { AdminFutureTask task = (AdminFutureTask) future; if (task.getMemberId().equals(internalId)) { -// this.logger.info("DEBUG: removeSystemMember cs cancelling: " + future); + // this.logger.info("DEBUG: removeSystemMember cs cancelling: " + future); future.cancel(true); } else { @@ -1609,7 +1549,7 @@ implements org.apache.geode.admin.AdminDistributedSystem, continue SERVERS; } catch (ExecutionException ex) { handle(ex); - return null; // Dead code + return null; // Dead code } finally { if (interrupted) { Thread.currentThread().interrupt(); @@ -1624,17 +1564,16 @@ implements org.apache.geode.admin.AdminDistributedSystem, found = true; } } // SERVERS - } + } - synchronized(this.applicationSet) { - for (Iterator iter = this.applicationSet.iterator(); - iter.hasNext() && !found; ) { + synchronized (this.applicationSet) { + for (Iterator iter = this.applicationSet.iterator(); iter.hasNext() && !found;) { Future future = (Future) iter.next(); try { if (future instanceof AdminFutureTask) { AdminFutureTask task = (AdminFutureTask) future; if (task.getMemberId().equals(internalId)) { - iter.remove(); // Only remove applications + iter.remove(); // Only remove applications found = true; if (future.isDone()) { member = (SystemMemberImpl) future.get(); @@ -1643,48 +1582,50 @@ implements org.apache.geode.admin.AdminDistributedSystem, } else { // This is not the member we are looking for... continue; - } + } } if (future.isDone()) { member = (SystemMemberImpl) future.get(); } else { -// this.logger.info("DEBUG: removeSystemMember as cancelling: " + future); + // this.logger.info("DEBUG: removeSystemMember as cancelling: " + future); future.cancel(true); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); checkCancellation(); - throw new RuntimeException(LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED.toLocalizedString(), ex); - + throw new RuntimeException( + LocalizedStrings.AdminDistributedSystemImpl_INTERRUPTED.toLocalizedString(), ex); + } catch (CancellationException ex) { continue; } catch (ExecutionException ex) { handle(ex); - return null; // Dead code + return null; // Dead code } InternalDistributedMember applicationId = member.getInternalId(); if (internalId.equals(applicationId)) { // found a match... - iter.remove(); // Only remove applications + iter.remove(); // Only remove applications found = true; } } - } + } if (found) { try { if (member != null) { member.setGemFireVM(null); } - + } catch (AdminException ex) { - logger.fatal(LocalizedMessage.create(LocalizedStrings.AdminDistributedSystem_UNEXPECTED_ADMINEXCEPTION), ex); + logger.fatal(LocalizedMessage + .create(LocalizedStrings.AdminDistributedSystem_UNEXPECTED_ADMINEXCEPTION), ex); } return member; - + } else { if (logger.isDebugEnabled()) { logger.debug("Couldn't remove member {}", internalId); @@ -1692,26 +1633,24 @@ implements org.apache.geode.admin.AdminDistributedSystem, return null; } } - - /** - * Builds the configuration needed to connect to a GfManagerAgent which is the - * main gateway into the internal.admin api. GfManagerAgent is used to - * actually connect to the distributed gemfire system. + + /** + * Builds the configuration needed to connect to a GfManagerAgent which is the main gateway into + * the internal.admin api. GfManagerAgent is used to actually connect to the distributed gemfire + * system. * * @param logWriter the LogWriterI18n to use for any logging * @return the configuration needed to connect to a GfManagerAgent */ // LOG: saves LogWriterLogger from AdminDistributedSystemImpl for RemoteGfManagerAgentConfig private GfManagerAgentConfig buildAgentConfig(InternalLogWriter logWriter) { - RemoteTransportConfig conf = new RemoteTransportConfig( - isMcastEnabled(), getDisableTcp(), - getDisableAutoReconnect(), - getBindAddress(), buildSSLConfig(), parseLocators(), + RemoteTransportConfig conf = new RemoteTransportConfig(isMcastEnabled(), getDisableTcp(), + getDisableAutoReconnect(), getBindAddress(), buildSSLConfig(), parseLocators(), getMembershipPortRange(), getTcpPort(), DistributionManager.ADMIN_ONLY_DM_TYPE); - return new GfManagerAgentConfig( - getSystemName(), conf, logWriter, this.alertLevel.getSeverity(), this, this); + return new GfManagerAgentConfig(getSystemName(), conf, logWriter, this.alertLevel.getSeverity(), + this, this); } - + protected SSLConfig buildSSLConfig() { SSLConfig conf = new SSLConfig(); if (getConfig() != null) { @@ -1723,10 +1662,9 @@ implements org.apache.geode.admin.AdminDistributedSystem, } return conf; } - + /** - * Returns the currently configured address to bind to when administering - * this system. + * Returns the currently configured address to bind to when administering this system. */ private String getBindAddress() { return this.config.getBindAddress(); @@ -1738,16 +1676,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, return ((ManagedEntity) member).isRunning(); } else { - // member must be an application VM. It is running + // member must be an application VM. It is running return true; } } /** Returns any member manager that is known to be running */ private SystemMember findFirstRunningMember() { - synchronized(this.cacheServerSet) { - SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); - iter.hasNext();){ + synchronized (this.cacheServerSet) { + SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); SystemMember member = null; for (;;) { @@ -1756,19 +1693,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { member = (SystemMember) future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue SERVERS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); - return null; // Dead code - } - finally { + return null; // Dead code + } finally { if (interrupted) { Thread.currentThread().interrupt(); } @@ -1781,9 +1714,8 @@ implements org.apache.geode.admin.AdminDistributedSystem, } } - synchronized(this.applicationSet) { - APPS: for (Iterator iter = this.applicationSet.iterator(); - iter.hasNext();) { + synchronized (this.applicationSet) { + APPS: for (Iterator iter = this.applicationSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); SystemMember member = null; for (;;) { @@ -1792,24 +1724,20 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { member = (SystemMember) future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying - } - catch (CancellationException ex) { + } catch (CancellationException ex) { continue APPS; - } - catch (ExecutionException ex) { + } catch (ExecutionException ex) { handle(ex); - return null; // Dead code - } - finally { + return null; // Dead code + } finally { if (interrupted) { Thread.currentThread().interrupt(); } } - } // for + } // for if (isRunning(member)) { return member; @@ -1821,48 +1749,45 @@ implements org.apache.geode.admin.AdminDistributedSystem, } /** - * Returns the instance of system member that is running either as a CacheVm - * or only ApplicationVm for the given string representation of the id. + * Returns the instance of system member that is running either as a CacheVm or only ApplicationVm + * for the given string representation of the id. * - * @param memberId - * string representation of the member identifier - * @return instance of system member which could be either as a CacheVm or - * Application VM + * @param memberId string representation of the member identifier + * @return instance of system member which could be either as a CacheVm or Application VM */ protected SystemMember findCacheOrAppVmById(String memberId) { SystemMember found = null; - + if (memberId != null) { try { boolean foundSender = false; CacheVm[] cacheVms = getCacheVms(); - - /* cacheVms could be null. See - * AdminDistributedSystemImpl.getCacheVmsCollection() for - * ExecutionException */ + + /* + * cacheVms could be null. See AdminDistributedSystemImpl.getCacheVmsCollection() for + * ExecutionException + */ if (cacheVms != null) { for (CacheVm cacheVm : cacheVms) { - if (cacheVm.getId().equals(memberId) && - cacheVm instanceof CacheVm) { - found = (SystemMember) cacheVm; + if (cacheVm.getId().equals(memberId) && cacheVm instanceof CacheVm) { + found = (SystemMember) cacheVm; foundSender = true; break; } } } - + if (!foundSender) { SystemMember[] appVms = getSystemMemberApplications(); - + for (SystemMember appVm : appVms) { - if (appVm.getId().equals(memberId) && - appVm instanceof SystemMember) { + if (appVm.getId().equals(memberId) && appVm instanceof SystemMember) { found = (SystemMember) appVm; foundSender = true; break; } } - + } } catch (AdminException e) { if (logger.isDebugEnabled()) { @@ -1870,21 +1795,21 @@ implements org.apache.geode.admin.AdminDistributedSystem, } } } - + return found; - } - + } + /** Returns true if any member application is known to be running */ protected boolean isAnyMemberRunning() { return findFirstRunningMember() != null; } - + // ------------------------------------------------------------------------- - // Health methods + // Health methods // ------------------------------------------------------------------------- - + /** - * Lazily initializes the GemFire health monitor + * Lazily initializes the GemFire health monitor * * @see #createGemFireHealth */ @@ -1895,7 +1820,10 @@ implements org.apache.geode.admin.AdminDistributedSystem, this.health = createGemFireHealth(this.gfManagerAgent); } catch (AdminException ex) { - throw new RuntimeAdminException(LocalizedStrings.AdminDistributedSystemImpl_AN_ADMINEXCEPTION_WAS_THROWN_WHILE_GETTING_THE_GEMFIRE_HEALTH.toLocalizedString(), ex); + throw new RuntimeAdminException( + LocalizedStrings.AdminDistributedSystemImpl_AN_ADMINEXCEPTION_WAS_THROWN_WHILE_GETTING_THE_GEMFIRE_HEALTH + .toLocalizedString(), + ex); } } @@ -1904,29 +1832,29 @@ implements org.apache.geode.admin.AdminDistributedSystem, } /** - * A "template factory" method for creating an instance of - * GemFireHealth. It can be overridden by subclasses - * to produce instances of different GemFireHealth + * A "template factory" method for creating an instance of GemFireHealth. It can be + * overridden by subclasses to produce instances of different GemFireHealth * implementations. * * @see #getGemFireHealth */ - protected GemFireHealth createGemFireHealth(GfManagerAgent agent) - throws AdminException { + protected GemFireHealth createGemFireHealth(GfManagerAgent agent) throws AdminException { if (agent == null) { - throw new IllegalStateException(LocalizedStrings.AdminDistributedSystemImpl_GFMANAGERAGENT_MUST_NOT_BE_NULL.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.AdminDistributedSystemImpl_GFMANAGERAGENT_MUST_NOT_BE_NULL + .toLocalizedString()); } return new GemFireHealthImpl(agent, this); } - + public CacheVm addCacheVm() throws AdminException { - return (CacheVm)addCacheServer(); + return (CacheVm) addCacheServer(); } - + public CacheServer addCacheServer() throws AdminException { CacheServerConfigImpl conf = new CacheServerConfigImpl(); - CacheServer server = createCacheServer(conf); + CacheServer server = createCacheServer(conf); setDistributionParameters(server); synchronized (this.cacheServerSet) { @@ -1937,10 +1865,9 @@ implements org.apache.geode.admin.AdminDistributedSystem, } private Collection getCacheVmsCollection() throws AdminException { - synchronized(this.cacheServerSet) { + synchronized (this.cacheServerSet) { Collection coll = new ArrayList(this.cacheServerSet.size()); - SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); - iter.hasNext(); ) { + SERVERS: for (Iterator iter = this.cacheServerSet.iterator(); iter.hasNext();) { Future future = (Future) iter.next(); Object get = null; for (;;) { @@ -1949,19 +1876,15 @@ implements org.apache.geode.admin.AdminDistributedSystem, try { get = future.get(); break; // success - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { interrupted = true; continue; // keep trying -