http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/LogCollator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/LogCollator.java b/geode-core/src/main/java/org/apache/geode/admin/internal/LogCollator.java index 6a183c5..83aa440 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/LogCollator.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/LogCollator.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; @@ -23,20 +21,19 @@ import org.apache.geode.internal.admin.ApplicationVM; import org.apache.geode.internal.logging.MergeLogFiles; import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.List; public class LogCollator { - + private GfManagerAgent system; private List logTails; - - public LogCollator() { - } - + + public LogCollator() {} + public String collateLogs(GfManagerAgent system) { try { if (system == null) { @@ -47,15 +44,14 @@ public class LogCollator { gatherActiveLogs(); gatherInactiveLogs(); return mergeLogs(); - } - finally { + } finally { this.system = null; this.logTails = null; } } // ------------------------------------------------------------------------- - + private String mergeLogs() { // combine logs... InputStream[] logFiles = new InputStream[this.logTails.size()]; @@ -65,14 +61,13 @@ public class LogCollator { logFiles[i] = new ByteArrayInputStream(loglet.tail.getBytes()); logFileNames[i] = loglet.name; } - + // delegate to MergeLogFiles... StringWriter writer = new StringWriter(); PrintWriter mergedLog = new PrintWriter(writer); if (!MergeLogFiles.mergeLogFiles(logFiles, logFileNames, mergedLog)) { return writer.toString(); - } - else { + } else { return ""; } } @@ -83,27 +78,17 @@ public class LogCollator { addLogFrom(runningsApps[i]); } } - + private void gatherInactiveLogs() { - /* not yet supported.... - if (useStopped) { - LogViewHelper helper = new LogViewHelper(); - for (Iterator iter = stoppedNodes.iterator(); iter.hasNext(); ) { - Object adminEntity = iter.next(); - helper.setAdminEntity(adminEntity); - try { - if (helper.logViewAvailable()) { - String[] logs = helper.getSystemLogs(); - addTail(allTails, logs, adminEntity.toString()); - } - } catch (Exception e) { - Service.getService().reportSystemError(e); - } - } - } - */ + /* + * not yet supported.... if (useStopped) { LogViewHelper helper = new LogViewHelper(); for + * (Iterator iter = stoppedNodes.iterator(); iter.hasNext(); ) { Object adminEntity = + * iter.next(); helper.setAdminEntity(adminEntity); try { if (helper.logViewAvailable()) { + * String[] logs = helper.getSystemLogs(); addTail(allTails, logs, adminEntity.toString()); } } + * catch (Exception e) { Service.getService().reportSystemError(e); } } } + */ } - + private void addLogFrom(GemFireVM vm) { String name = null; name = vm.toString(); @@ -113,25 +98,24 @@ public class LogCollator { private void addTail(String logName, String[] logs) { if (logs.length > 0) { - String tail = (logs.length > 1) ? logs[1] : logs[0]; + String tail = (logs.length > 1) ? logs[1] : logs[0]; this.logTails.add(new Loglet(logName, tail)); } } /* - public void setUseStoppedManagers(boolean useStopped) { - this.useStopped = useStopped; - } - */ + * public void setUseStoppedManagers(boolean useStopped) { this.useStopped = useStopped; } + */ private static class Loglet { String name; String tail; + Loglet(String name, String tail) { this.name = name; this.tail = tail; } } - + }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigImpl.java index 3f1e0d3..fc41e5f 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigImpl.java @@ -1,23 +1,21 @@ /* - * 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; -//import org.apache.geode.admin.DistributedSystemConfig; -//import org.apache.geode.admin.ManagedEntity; +// import org.apache.geode.admin.DistributedSystemConfig; +// import org.apache.geode.admin.ManagedEntity; import org.apache.geode.admin.ManagedEntityConfig; import org.apache.geode.internal.admin.GemFireVM; import org.apache.geode.internal.i18n.LocalizedStrings; @@ -28,15 +26,13 @@ import java.io.File; import java.net.*; /** - * The abstract superclass of objects that configure a managed entity - * such as a GemFire cache server or a distribution locator. - * It contains configuration state and behavior common to all managed + * The abstract superclass of objects that configure a managed entity such as a GemFire cache server + * or a distribution locator. It contains configuration state and behavior common to all managed * entities. * * @since GemFire 4.0 */ -public abstract class ManagedEntityConfigImpl - implements ManagedEntityConfig { +public abstract class ManagedEntityConfigImpl implements ManagedEntityConfig { /** The name of the host on which the managed entity runs */ private String host; @@ -50,23 +46,26 @@ public abstract class ManagedEntityConfigImpl /** Command used to launch locator on remote machine */ private String remoteCommand; - /** The managed entity configured by this object. + /** + * The managed entity configured by this object. * - * @see #isReadOnly */ + * @see #isReadOnly + */ private InternalManagedEntity entity = null; - ///////////////////// Static Methods ///////////////////// + ///////////////////// Static Methods ///////////////////// /** - * Returns the {@linkplain InetAddress#getCanonicalHostName - * canonical name} of the local machine. + * Returns the {@linkplain InetAddress#getCanonicalHostName canonical name} of the local machine. */ protected static String getLocalHostName() { try { return SocketCreator.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException ex) { - IllegalStateException ex2 = new IllegalStateException(LocalizedStrings.ManagedEntityConfigImpl_COULD_NOT_DETERMINE_LOCALHOST.toLocalizedString()); + IllegalStateException ex2 = new IllegalStateException( + LocalizedStrings.ManagedEntityConfigImpl_COULD_NOT_DETERMINE_LOCALHOST + .toLocalizedString()); ex2.initCause(ex); throw ex2; } @@ -81,14 +80,14 @@ public abstract class ManagedEntityConfigImpl } /** - * Returns the location of the GemFire product installation. This - * is determined by finding the location of the gemfire jar - * and working backwards. + * Returns the location of the GemFire product installation. This is determined by finding the + * location of the gemfire jar and working backwards. */ private static File getGemFireInstallation() { URL url = GemFireVersion.getJarURL(); if (url == null) { - throw new IllegalStateException(LocalizedStrings.ManagedEntityConfigImpl_COULD_NOT_FIND_GEMFIREJAR.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.ManagedEntityConfigImpl_COULD_NOT_FIND_GEMFIREJAR.toLocalizedString()); } File gemfireJar = new File(url.getPath()); @@ -98,24 +97,21 @@ public abstract class ManagedEntityConfigImpl return product; } - ////////////////////// Constructors ////////////////////// + ////////////////////// Constructors ////////////////////// /** - * Creates a <code>ManagedEntityConfigImpl</code> with the default - * configuration. + * Creates a <code>ManagedEntityConfigImpl</code> with the default configuration. */ protected ManagedEntityConfigImpl() { this.host = getLocalHostName(); - this.workingDirectory = - getCurrentWorkingDirectory().getAbsolutePath(); - this.productDirectory = - getGemFireInstallation().getAbsolutePath(); - this.remoteCommand = null; // Delegate to AdminDistributedSystem + this.workingDirectory = getCurrentWorkingDirectory().getAbsolutePath(); + this.productDirectory = getGemFireInstallation().getAbsolutePath(); + this.remoteCommand = null; // Delegate to AdminDistributedSystem } /** - * Creates a new <code>ManagedEntityConfigImpl</code> based on the - * configuration of a running <code>GemFireVM</code> + * Creates a new <code>ManagedEntityConfigImpl</code> based on the configuration of a running + * <code>GemFireVM</code> */ protected ManagedEntityConfigImpl(GemFireVM vm) { this.host = SocketCreator.getHostName(vm.getHost()); @@ -125,9 +121,8 @@ public abstract class ManagedEntityConfigImpl } /** - * A copy constructor that creates a new - * <code>ManagedEntityConfigImpl</code> with the same configuration - * as another <code>ManagedEntityConfig</code>. + * A copy constructor that creates a new <code>ManagedEntityConfigImpl</code> with the same + * configuration as another <code>ManagedEntityConfig</code>. */ protected ManagedEntityConfigImpl(ManagedEntityConfig other) { this.host = other.getHost(); @@ -136,32 +131,33 @@ public abstract class ManagedEntityConfigImpl this.remoteCommand = other.getRemoteCommand(); } - //////////////////// Instance Methods //////////////////// + //////////////////// Instance Methods //////////////////// /** - * Checks to see if this config object is "read only". If it is, - * then an {@link IllegalStateException} is thrown. It should be - * called by every setter method. + * Checks to see if this config object is "read only". If it is, then an + * {@link IllegalStateException} is thrown. It should be called by every setter method. * * @see #isReadOnly */ public void checkReadOnly() { if (this.isReadOnly()) { - throw new IllegalStateException(LocalizedStrings.ManagedEntityConfigImpl_THIS_CONFIGURATION_CANNOT_BE_MODIFIED_WHILE_ITS_MANAGED_ENTITY_IS_RUNNING.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.ManagedEntityConfigImpl_THIS_CONFIGURATION_CANNOT_BE_MODIFIED_WHILE_ITS_MANAGED_ENTITY_IS_RUNNING + .toLocalizedString()); } } /** - * Returns whether or not this <code>ManagedEntityConfigImpl</code> - * is read-only (can be modified). + * Returns whether or not this <code>ManagedEntityConfigImpl</code> is read-only (can be + * modified). */ protected boolean isReadOnly() { return this.entity != null && this.entity.isRunning(); } /** - * Sets the entity that is configured by this config object. Once - * the entity is running, the config object cannot be modified. + * Sets the entity that is configured by this config object. Once the entity is running, the + * config object cannot be modified. * * @see #checkReadOnly */ @@ -170,8 +166,7 @@ public abstract class ManagedEntityConfigImpl } /** - * Notifies any configuration listeners that this configuration has - * changed. + * Notifies any configuration listeners that this configuration has changed. */ protected abstract void configChanged(); @@ -219,12 +214,12 @@ public abstract class ManagedEntityConfigImpl /** * Validates this configuration. * - * @throws IllegalStateException - * If this config is not valid + * @throws IllegalStateException If this config is not valid */ public void validate() { if (InetAddressUtil.validateHost(this.host) == null) { - throw new IllegalStateException(LocalizedStrings.ManagedEntityConfigImpl_INVALID_HOST_0.toLocalizedString(this.host)); + throw new IllegalStateException( + LocalizedStrings.ManagedEntityConfigImpl_INVALID_HOST_0.toLocalizedString(this.host)); } } @@ -232,8 +227,7 @@ public abstract class ManagedEntityConfigImpl public Object clone() throws CloneNotSupportedException { // Since all fields are immutable objects, no deep cloning is // necessary. - ManagedEntityConfigImpl clone = - (ManagedEntityConfigImpl) super.clone(); + ManagedEntityConfigImpl clone = (ManagedEntityConfigImpl) super.clone(); clone.entity = null; return clone; } @@ -246,7 +240,7 @@ public abstract class ManagedEntityConfigImpl StringBuffer sb = new StringBuffer(); sb.append(className); - + sb.append(" host="); sb.append(this.getHost()); sb.append(" workingDirectory="); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXml.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXml.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXml.java index 6313e21..4e5198e 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXml.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXml.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; @@ -24,29 +22,26 @@ import org.xml.sax.*; import java.io.InputStream; /** - * The abstract superclass of classes that convert XML into a {@link - * org.apache.geode.admin.DistributedSystemConfig} and vice versa. - * It provides helper methods and constants. + * The abstract superclass of classes that convert XML into a + * {@link org.apache.geode.admin.DistributedSystemConfig} and vice versa. It provides helper methods + * and constants. * * @since GemFire 4.0 */ abstract class ManagedEntityConfigXml implements EntityResolver, ErrorHandler { /** The location of the DTD file */ - protected static final String DTD_LOCATION = - "/org/apache/geode/admin/doc-files/ds5_0.dtd"; + protected static final String DTD_LOCATION = "/org/apache/geode/admin/doc-files/ds5_0.dtd"; /** The URL for the DTD */ - protected static final String SYSTEM_ID = - "http://www.gemstone.com/dtd/ds5_0.dtd"; + protected static final String SYSTEM_ID = "http://www.gemstone.com/dtd/ds5_0.dtd"; /** The public ID for the DTD */ - protected static final String PUBLIC_ID = - "-//GemStone Systems, Inc.//GemFire Distributed System 5.0//EN"; + protected static final String PUBLIC_ID = + "-//GemStone Systems, Inc.//GemFire Distributed System 5.0//EN"; /** The name of the <code>distributed-system</code> element. */ - public static final String DISTRIBUTED_SYSTEM = - "distributed-system"; + public static final String DISTRIBUTED_SYSTEM = "distributed-system"; /** The name of the <code>id</code> attribute. */ public static final String ID = "id"; @@ -97,46 +92,48 @@ abstract class ManagedEntityConfigXml implements EntityResolver, ErrorHandler { public static final String PROPERTY = "property"; /** Name of the <code>authentication-required</code> attribute */ - public static final String AUTHENTICATION_REQUIRED = - "authentication-required"; + public static final String AUTHENTICATION_REQUIRED = "authentication-required"; /** The name of the <code>key</code> element */ public static final String KEY = "key"; /** The name of the <code>value</code> element */ public static final String VALUE = "value"; - + /** The name of the <code>classpath</code> element */ public static final String CLASSPATH = "classpath"; - /////////////////////// Instance Methods /////////////////////// + /////////////////////// Instance Methods /////////////////////// /** - * Given a public id, attempt to resolve it to a DTD. Returns an - * <code>InputSoure</code> for the DTD. + * Given a public id, attempt to resolve it to a DTD. Returns an <code>InputSoure</code> for the + * DTD. */ - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException { + public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (publicId == null || systemId == null) { - throw new SAXException(LocalizedStrings.ManagedEntityConfigXml_PUBLIC_ID_0_SYSTEM_ID_1.toLocalizedString(new Object[] {publicId, systemId})); + throw new SAXException(LocalizedStrings.ManagedEntityConfigXml_PUBLIC_ID_0_SYSTEM_ID_1 + .toLocalizedString(new Object[] {publicId, systemId})); } // Figure out the location for the publicId. String location = DTD_LOCATION; InputSource result; -// if (location != null) (cannot be null) + // if (location != null) (cannot be null) { InputStream stream = ClassPathLoader.getLatest().getResourceAsStream(getClass(), location); if (stream != null) { result = new InputSource(stream); } else { - throw new SAXNotRecognizedException(LocalizedStrings.ManagedEntityConfigXml_DTD_NOT_FOUND_0.toLocalizedString(location)); + throw new SAXNotRecognizedException( + LocalizedStrings.ManagedEntityConfigXml_DTD_NOT_FOUND_0.toLocalizedString(location)); } -// } else { -// throw new SAXNotRecognizedException(LocalizedStrings.ManagedEntityConfigXml_COULD_NOT_FIND_DTD_FOR_0_1.toLocalizedString(new Object[] {publicId, systemId})); + // } else { + // throw new + // SAXNotRecognizedException(LocalizedStrings.ManagedEntityConfigXml_COULD_NOT_FIND_DTD_FOR_0_1.toLocalizedString(new + // Object[] {publicId, systemId})); } return result; @@ -145,7 +142,7 @@ abstract class ManagedEntityConfigXml implements EntityResolver, ErrorHandler { /** * Warnings are ignored */ - public void warning(SAXParseException ex) throws SAXException { + public void warning(SAXParseException ex) throws SAXException { } @@ -153,16 +150,18 @@ abstract class ManagedEntityConfigXml implements EntityResolver, ErrorHandler { * Throws a {@link org.apache.geode.cache.CacheXmlException} */ public void error(SAXParseException ex) throws SAXException { - IllegalArgumentException ex2 = new IllegalArgumentException(LocalizedStrings.ManagedEntityConfigXml_ERROR_WHILE_PARSING_XML.toLocalizedString()); + IllegalArgumentException ex2 = new IllegalArgumentException( + LocalizedStrings.ManagedEntityConfigXml_ERROR_WHILE_PARSING_XML.toLocalizedString()); ex2.initCause(ex); throw ex2; } - + /** * Throws a {@link org.apache.geode.cache.CacheXmlException} */ public void fatalError(SAXParseException ex) throws SAXException { - IllegalArgumentException ex2 = new IllegalArgumentException(LocalizedStrings.ManagedEntityConfigXml_FATAL_ERROR_WHILE_PARSING_XML.toLocalizedString()); + IllegalArgumentException ex2 = new IllegalArgumentException( + LocalizedStrings.ManagedEntityConfigXml_FATAL_ERROR_WHILE_PARSING_XML.toLocalizedString()); ex2.initCause(ex); throw ex2; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlGenerator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlGenerator.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlGenerator.java index 80f183d..80732cc 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlGenerator.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlGenerator.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; @@ -20,61 +18,57 @@ import org.apache.geode.admin.*; import org.apache.geode.internal.Assert; import org.apache.geode.internal.i18n.LocalizedStrings; -import javax.xml.transform.*; -//import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.*; +// import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; import org.xml.sax.*; -//import org.xml.sax.ext.*; -import org.xml.sax.helpers.AttributesImpl; +// import org.xml.sax.ext.*; +import org.xml.sax.helpers.AttributesImpl; import java.io.*; import java.util.*; /** * Generates XML data that represents the managed entities in an - * <code>AdminDistributedSystem</code>. This class is used mainly for - * testing. + * <code>AdminDistributedSystem</code>. This class is used mainly for testing. * * @since GemFire 4.0 */ -public class ManagedEntityConfigXmlGenerator - extends ManagedEntityConfigXml implements XMLReader { +public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml implements XMLReader { /** An empty <code>Attributes</code> */ private static Attributes EMPTY = new AttributesImpl(); - ///////////////////////// Instance Fields //////////////////////// + ///////////////////////// Instance Fields //////////////////////// - /** The <code>AdminDistributedSystem</code> for which we are - * generating XML */ + /** + * The <code>AdminDistributedSystem</code> for which we are generating XML + */ private AdminDistributedSystem system; /** The content handler to which SAX events are generated */ private ContentHandler handler; - ///////////////////////// Static Methods //////////////////////// + ///////////////////////// Static Methods //////////////////////// /** - * Generates an XML representation of all of the managed entities in - * the given <code>AdminDistributedSystem</code>. + * Generates an XML representation of all of the managed entities in the given + * <code>AdminDistributedSystem</code>. */ - public static void generate(AdminDistributedSystem system, - PrintWriter pw) { + public static void generate(AdminDistributedSystem system, PrintWriter pw) { (new ManagedEntityConfigXmlGenerator(system)).generate(pw); } - ///////////////////////// Constructors ////////////////////////// + ///////////////////////// Constructors ////////////////////////// /** - * Creates a new generator for the given - * <code>AdminDistributedSystem</code>. + * Creates a new generator for the given <code>AdminDistributedSystem</code>. */ - private ManagedEntityConfigXmlGenerator(AdminDistributedSystem - system) { + private ManagedEntityConfigXmlGenerator(AdminDistributedSystem system) { this.system = system; } - /////////////////////// Instance Methods /////////////////////// + /////////////////////// Instance Methods /////////////////////// /** * Generates XML and writes it to the given <code>PrintWriter</code> @@ -97,16 +91,17 @@ public class ManagedEntityConfigXmlGenerator pw.flush(); } catch (Exception ex) { - RuntimeException ex2 = new RuntimeException(LocalizedStrings.ManagedEntityConfigXmlGenerator_EXCEPTION_THROWN_WHILE_GENERATING_XML.toLocalizedString()); + RuntimeException ex2 = new RuntimeException( + LocalizedStrings.ManagedEntityConfigXmlGenerator_EXCEPTION_THROWN_WHILE_GENERATING_XML + .toLocalizedString()); ex2.initCause(ex); throw ex2; } } /** - * Called by the transformer to parse the "input source". We ignore - * the input source and, instead, generate SAX events to the {@link - * #setContentHandler ContentHandler}. + * Called by the transformer to parse the "input source". We ignore the input source and, instead, + * generate SAX events to the {@link #setContentHandler ContentHandler}. */ public void parse(InputSource input) throws SAXException { Assert.assertTrue(this.handler != null); @@ -115,8 +110,7 @@ public class ManagedEntityConfigXmlGenerator AttributesImpl atts = new AttributesImpl(); - atts.addAttribute("", "", ID, "", - String.valueOf(this.system.getConfig().getSystemId())); + atts.addAttribute("", "", ID, "", String.valueOf(this.system.getConfig().getSystemId())); handler.startElement("", DISTRIBUTED_SYSTEM, DISTRIBUTED_SYSTEM, atts); @@ -128,7 +122,10 @@ public class ManagedEntityConfigXmlGenerator generateCacheServers(); } catch (AdminException ex) { - throw new SAXException(LocalizedStrings.ManagedEntityConfigXmlGenerator_AN_ADMINEXCEPTION_WAS_THROWN_WHILE_GENERATING_XML.toLocalizedString(), ex); + throw new SAXException( + LocalizedStrings.ManagedEntityConfigXmlGenerator_AN_ADMINEXCEPTION_WAS_THROWN_WHILE_GENERATING_XML + .toLocalizedString(), + ex); } handler.endElement("", DISTRIBUTED_SYSTEM, DISTRIBUTED_SYSTEM); @@ -143,8 +140,7 @@ public class ManagedEntityConfigXmlGenerator handler.startElement("", REMOTE_COMMAND, REMOTE_COMMAND, EMPTY); - handler.characters(remoteCommand.toCharArray(), 0, - remoteCommand.length()); + handler.characters(remoteCommand.toCharArray(), 0, remoteCommand.length()); handler.endElement("", REMOTE_COMMAND, REMOTE_COMMAND); } @@ -156,7 +152,7 @@ public class ManagedEntityConfigXmlGenerator handler.startElement("", LOCATORS, LOCATORS, EMPTY); generateLocators(); - + handler.endElement("", LOCATORS, LOCATORS); } @@ -164,8 +160,7 @@ public class ManagedEntityConfigXmlGenerator * Generates XML for the distributed system's locators */ private void generateLocators() throws SAXException { - DistributionLocator[] locators = - this.system.getDistributionLocators(); + DistributionLocator[] locators = this.system.getDistributionLocators(); for (int i = 0; i < locators.length; i++) { generateLocator(locators[i].getConfig()); } @@ -174,12 +169,10 @@ public class ManagedEntityConfigXmlGenerator /** * Generates XML for a locator */ - private void generateLocator(DistributionLocatorConfig config) - throws SAXException { - + private void generateLocator(DistributionLocatorConfig config) throws SAXException { + AttributesImpl atts = new AttributesImpl(); - atts.addAttribute("", "", PORT, "", - String.valueOf(config.getPort())); + atts.addAttribute("", "", PORT, "", String.valueOf(config.getPort())); handler.startElement("", LOCATOR, LOCATOR, atts); @@ -191,8 +184,7 @@ public class ManagedEntityConfigXmlGenerator /** * Generates XML for attributes common to all managed entities. */ - private void generateEntityConfig(ManagedEntityConfig config) - throws SAXException { + private void generateEntityConfig(ManagedEntityConfig config) throws SAXException { String host = config.getHost(); if (host != null) { @@ -204,31 +196,27 @@ public class ManagedEntityConfigXmlGenerator String remoteCommand = config.getRemoteCommand(); if (remoteCommand != null) { handler.startElement("", REMOTE_COMMAND, REMOTE_COMMAND, EMPTY); - handler.characters(remoteCommand.toCharArray(), 0, - remoteCommand.length()); + handler.characters(remoteCommand.toCharArray(), 0, remoteCommand.length()); handler.endElement("", REMOTE_COMMAND, REMOTE_COMMAND); } String workingDirectory = config.getWorkingDirectory(); if (workingDirectory != null) { handler.startElement("", WORKING_DIRECTORY, WORKING_DIRECTORY, EMPTY); - handler.characters(workingDirectory.toCharArray(), 0, - workingDirectory.length()); + handler.characters(workingDirectory.toCharArray(), 0, workingDirectory.length()); handler.endElement("", WORKING_DIRECTORY, WORKING_DIRECTORY); } String productDirectory = config.getProductDirectory(); if (productDirectory != null) { handler.startElement("", PRODUCT_DIRECTORY, PRODUCT_DIRECTORY, EMPTY); - handler.characters(productDirectory.toCharArray(), 0, - productDirectory.length()); + handler.characters(productDirectory.toCharArray(), 0, productDirectory.length()); handler.endElement("", PRODUCT_DIRECTORY, PRODUCT_DIRECTORY); } } /** - * Generates XML for the SSL configuration of the distributed - * system. + * Generates XML for the SSL configuration of the distributed system. */ private void generateSSL() throws SAXException { DistributedSystemConfig config = this.system.getConfig(); @@ -240,33 +228,30 @@ public class ManagedEntityConfigXmlGenerator AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", AUTHENTICATION_REQUIRED, "", - String.valueOf(config.isSSLAuthenticationRequired())); + String.valueOf(config.isSSLAuthenticationRequired())); handler.startElement("", SSL, SSL, atts); String protocols = config.getSSLProtocols(); if (protocols != null) { handler.startElement("", PROTOCOLS, PROTOCOLS, EMPTY); - handler.characters(protocols.toCharArray(), 0, - protocols.length()); + handler.characters(protocols.toCharArray(), 0, protocols.length()); handler.endElement("", PROTOCOLS, PROTOCOLS); } String ciphers = config.getSSLCiphers(); if (ciphers != null) { handler.startElement("", CIPHERS, CIPHERS, EMPTY); - handler.characters(ciphers.toCharArray(), 0, - ciphers.length()); + handler.characters(ciphers.toCharArray(), 0, ciphers.length()); handler.endElement("", CIPHERS, CIPHERS); } Properties sslProps = config.getSSLProperties(); - for (Iterator iter = sslProps.entrySet().iterator(); - iter.hasNext(); ) { + for (Iterator iter = sslProps.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); - + handler.startElement("", PROPERTY, PROPERTY, EMPTY); handler.startElement("", KEY, KEY, EMPTY); @@ -284,11 +269,9 @@ public class ManagedEntityConfigXmlGenerator } /** - * Generates an XML representation of the - * <code>CacheServer</code>s in the distributed system. + * Generates an XML representation of the <code>CacheServer</code>s in the distributed system. */ - private void generateCacheServers() - throws SAXException, AdminException { + private void generateCacheServers() throws SAXException, AdminException { CacheServer[] servers = this.system.getCacheServers(); for (int i = 0; i < servers.length; i++) { @@ -297,11 +280,9 @@ public class ManagedEntityConfigXmlGenerator } /** - * Generates an XML representation of a - * <code>CacheServerConfig</code>. + * Generates an XML representation of a <code>CacheServerConfig</code>. */ - private void generateCacheServer(CacheServerConfig config) - throws SAXException { + private void generateCacheServer(CacheServerConfig config) throws SAXException { handler.startElement("", CACHE_SERVER, CACHE_SERVER, EMPTY); @@ -310,8 +291,7 @@ public class ManagedEntityConfigXmlGenerator String classpath = config.getClassPath(); if (classpath != null) { handler.startElement("", CLASSPATH, CLASSPATH, EMPTY); - handler.characters(classpath.toCharArray(), 0, - classpath.length()); + handler.characters(classpath.toCharArray(), 0, classpath.length()); handler.endElement("", CLASSPATH, CLASSPATH); } @@ -323,36 +303,36 @@ public class ManagedEntityConfigXmlGenerator */ public void setContentHandler(ContentHandler handler) { this.handler = handler; - } + } public ContentHandler getContentHandler() { return this.handler; - } + } public ErrorHandler getErrorHandler() { return this; } - ////////// Inherited methods that don't do anything ////////// + ////////// Inherited methods that don't do anything ////////// public boolean getFeature(String name) - throws SAXNotRecognizedException, SAXNotSupportedException { + throws SAXNotRecognizedException, SAXNotSupportedException { return false; } public void setFeature(String name, boolean value) - throws SAXNotRecognizedException, SAXNotSupportedException { + throws SAXNotRecognizedException, SAXNotSupportedException { } public Object getProperty(String name) - throws SAXNotRecognizedException, SAXNotSupportedException { + throws SAXNotRecognizedException, SAXNotSupportedException { return null; } public void setProperty(String name, Object value) - throws SAXNotRecognizedException, SAXNotSupportedException { + throws SAXNotRecognizedException, SAXNotSupportedException { } @@ -363,7 +343,7 @@ public class ManagedEntityConfigXmlGenerator public EntityResolver getEntityResolver() { return this; } - + public void setDTDHandler(DTDHandler handler) { } @@ -376,8 +356,7 @@ public class ManagedEntityConfigXmlGenerator } - public void parse(String systemId) - throws IOException, SAXException { + public void parse(String systemId) throws IOException, SAXException { } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlParser.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlParser.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlParser.java index 1065caf..29b81f4 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlParser.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityConfigXmlParser.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; @@ -28,13 +26,11 @@ import java.io.*; import java.util.*; /** - * Parses an XML file and configures a {@link DistributedSystemConfig} - * from it. + * Parses an XML file and configures a {@link DistributedSystemConfig} from it. * * @since GemFire 4.0 */ -public class ManagedEntityConfigXmlParser - extends ManagedEntityConfigXml implements ContentHandler { +public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml implements ContentHandler { /** The <code>DistributedSystemConfig</code> to be configured */ private DistributedSystemConfig config; @@ -42,19 +38,15 @@ public class ManagedEntityConfigXmlParser /** The stack of intermediate values used while parsing */ private Stack stack = new Stack(); - ////////////////////// Static Methods ////////////////////// + ////////////////////// Static Methods ////////////////////// /** - * Parses XML data and from it configures a - * <code>DistributedSystemConfig</code>. + * Parses XML data and from it configures a <code>DistributedSystemConfig</code>. * - * @throws AdminXmlException - * If an error is encountered while parsing the XML + * @throws AdminXmlException If an error is encountered while parsing the XML */ - public static void parse(InputStream is, - DistributedSystemConfig config) { - ManagedEntityConfigXmlParser handler = - new ManagedEntityConfigXmlParser(); + public static void parse(InputStream is, DistributedSystemConfig config) { + ManagedEntityConfigXmlParser handler = new ManagedEntityConfigXmlParser(); handler.config = config; try { @@ -72,7 +64,7 @@ public class ManagedEntityConfigXmlParser } else if (ex instanceof SAXException) { // Silly JDK 1.4.2 XML parser wraps RunTime exceptions in a - // SAXException. Pshaw! + // SAXException. Pshaw! SAXException sax = (SAXException) ex; Exception cause = sax.getException(); @@ -81,34 +73,35 @@ public class ManagedEntityConfigXmlParser } } - throw new AdminXmlException(LocalizedStrings.ManagedEntityConfigXmlParser_WHILE_PARSING_XML.toLocalizedString(), ex); + throw new AdminXmlException( + LocalizedStrings.ManagedEntityConfigXmlParser_WHILE_PARSING_XML.toLocalizedString(), ex); } } /** * Helper method for parsing an integer * - * @throws org.apache.geode.cache.CacheXmlException - * If <code>s</code> is a malformed integer + * @throws org.apache.geode.cache.CacheXmlException If <code>s</code> is a malformed integer */ private static int parseInt(String s) { try { return Integer.parseInt(s); } catch (NumberFormatException ex) { - throw new AdminXmlException(LocalizedStrings.ManagedEntityConfigXmlParser_MALFORMED_INTEGER_0.toLocalizedString(s), ex); + throw new AdminXmlException( + LocalizedStrings.ManagedEntityConfigXmlParser_MALFORMED_INTEGER_0.toLocalizedString(s), + ex); } } - ////////////////////// Instance Methods ////////////////////// + ////////////////////// Instance Methods ////////////////////// -// if (this.system.isMcastEnabled()) { -// generateMulticast(); -// } + // if (this.system.isMcastEnabled()) { + // generateMulticast(); + // } - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) - throws SAXException { + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) + throws SAXException { if (qName.equals(DISTRIBUTED_SYSTEM)) { startDistributedSystem(atts); @@ -118,7 +111,7 @@ public class ManagedEntityConfigXmlParser } else if (qName.equals(LOCATORS)) { startLocators(atts); - + } else if (qName.equals(MULTICAST)) { startMulticast(atts); @@ -159,13 +152,13 @@ public class ManagedEntityConfigXmlParser startClassPath(atts); } else { - throw new AdminXmlException(LocalizedStrings.ManagedEntityConfigXmlParser_UNKNOWN_XML_ELEMENT_0.toLocalizedString(qName)); + throw new AdminXmlException( + LocalizedStrings.ManagedEntityConfigXmlParser_UNKNOWN_XML_ELEMENT_0 + .toLocalizedString(qName)); } } - public void endElement(String namespaceURI, String localName, - String qName) - throws SAXException { + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (qName.equals(DISTRIBUTED_SYSTEM)) { endDistributedSystem(); @@ -216,13 +209,15 @@ public class ManagedEntityConfigXmlParser endClassPath(); } else { - throw new AdminXmlException(LocalizedStrings.ManagedEntityConfigXmlParser_UNKNOWN_XML_ELEMENT_0.toLocalizedString(qName)); + throw new AdminXmlException( + LocalizedStrings.ManagedEntityConfigXmlParser_UNKNOWN_XML_ELEMENT_0 + .toLocalizedString(qName)); } } /** - * When a <code>distributed-system</code> element is encountered, we - * push the <code>DistributedSystemConfig</code> on the stack. + * When a <code>distributed-system</code> element is encountered, we push the + * <code>DistributedSystemConfig</code> on the stack. */ private void startDistributedSystem(Attributes atts) { Assert.assertTrue(stack.isEmpty()); @@ -231,7 +226,7 @@ public class ManagedEntityConfigXmlParser if (id != null) { this.config.setSystemId(id); } - + String disable_tcp = atts.getValue(DISABLE_TCP); if (disable_tcp != null) { this.config.setDisableTcp(DISABLE_TCP.equalsIgnoreCase("true")); @@ -244,17 +239,16 @@ public class ManagedEntityConfigXmlParser * When a <code>distributed-system</code> element is finished */ private void endDistributedSystem() { - + } /** * When a <code>multicast</code> is first encountered, get the - * <code>DistributedSystemConfig</code> off of the top of the stack - * and set its multicast config appropriately. + * <code>DistributedSystemConfig</code> off of the top of the stack and set its multicast config + * appropriately. */ private void startMulticast(Attributes atts) { - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); String port = atts.getValue(PORT); config.setMcastPort(parseInt(port)); @@ -270,19 +264,17 @@ public class ManagedEntityConfigXmlParser } /** - * Starts a <code>remote-command</code> element. The item on top of - * the stack may be a <code>DistributedSystemConfig</code> or it - * might be a <code>ManagedEntityConfig</code>. + * Starts a <code>remote-command</code> element. The item on top of the stack may be a + * <code>DistributedSystemConfig</code> or it might be a <code>ManagedEntityConfig</code>. */ private void startRemoteCommand(Attributes atts) { } /** - * Ends a <code>remote-command</code> element. Pop the command off - * the top of the stack and set it on the - * <code>DistributedSystemConfig</code> or it might be a - * <code>ManagedEntityConfig</code> on top of the stack. + * Ends a <code>remote-command</code> element. Pop the command off the top of the stack and set it + * on the <code>DistributedSystemConfig</code> or it might be a <code>ManagedEntityConfig</code> + * on top of the stack. */ private void endRemoteCommand() { String remoteCommand = popString(); @@ -296,8 +288,7 @@ public class ManagedEntityConfigXmlParser ((ManagedEntityConfig) top).setRemoteCommand(remoteCommand); } else { - String s = "Did not expect a " + top.getClass().getName() + - " on top of the stack"; + String s = "Did not expect a " + top.getClass().getName() + " on top of the stack"; Assert.assertTrue(false, s); } } @@ -313,13 +304,11 @@ public class ManagedEntityConfigXmlParser private void startLocator(Attributes atts) { String port = atts.getValue(PORT); - DistributedSystemConfig system = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig system = (DistributedSystemConfig) stack.peek(); system.setMcastPort(0); - DistributionLocatorConfig config = - system.createDistributionLocatorConfig(); - + DistributionLocatorConfig config = system.createDistributionLocatorConfig(); + config.setPort(parseInt(port)); stack.push(config); @@ -335,8 +324,7 @@ public class ManagedEntityConfigXmlParser } /** - * We assume that there is a <code>ManagedEntityConfig</code> on top - * of the stack. + * We assume that there is a <code>ManagedEntityConfig</code> on top of the stack. */ private void endHost() { String host = popString(); @@ -365,12 +353,10 @@ public class ManagedEntityConfigXmlParser } private void startSSL(Attributes atts) { - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); config.setSSLEnabled(true); - String authenticationRequired = - atts.getValue(AUTHENTICATION_REQUIRED); + String authenticationRequired = atts.getValue(AUTHENTICATION_REQUIRED); config.setSSLAuthenticationRequired(Boolean.valueOf(authenticationRequired).booleanValue()); } @@ -384,8 +370,7 @@ public class ManagedEntityConfigXmlParser private void endProtocols() { String protocols = popString(); - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); config.setSSLProtocols(protocols); } @@ -395,8 +380,7 @@ public class ManagedEntityConfigXmlParser private void endCiphers() { String ciphers = popString(); - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); config.setSSLCiphers(ciphers); } @@ -407,8 +391,7 @@ public class ManagedEntityConfigXmlParser private void endProperty() { String value = popString(); String key = popString(); - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); config.addSSLProperty(key, value); } @@ -431,10 +414,8 @@ public class ManagedEntityConfigXmlParser } private void startCacheServer(Attributes atts) { - DistributedSystemConfig config = - (DistributedSystemConfig) stack.peek(); - CacheServerConfig server = - config.createCacheServerConfig(); + DistributedSystemConfig config = (DistributedSystemConfig) stack.peek(); + CacheServerConfig server = config.createCacheServerConfig(); stack.push(server); } @@ -468,13 +449,10 @@ public class ManagedEntityConfigXmlParser } /** - * Long strings in XML files may generate multiple - * <code>characters</code> callbacks. Coalesce multiple callbacks - * into one big string by using a <code>StringBuffer</code>. See - * bug 32122. + * Long strings in XML files may generate multiple <code>characters</code> callbacks. Coalesce + * multiple callbacks into one big string by using a <code>StringBuffer</code>. See bug 32122. */ - public void characters(char[] ch, int start, int length) - throws SAXException { + public void characters(char[] ch, int start, int length) throws SAXException { Object top = stack.peek(); @@ -490,44 +468,39 @@ public class ManagedEntityConfigXmlParser sb.append(ch, start, length); } - ////////// Inherited methods that don't do anything ////////// + ////////// Inherited methods that don't do anything ////////// - public void setDocumentLocator(Locator locator) { } + public void setDocumentLocator(Locator locator) {} - public void startDocument() throws SAXException { } + public void startDocument() throws SAXException {} - public void endDocument() throws SAXException { } + public void endDocument() throws SAXException {} - public void startPrefixMapping(String prefix, String uri) - throws SAXException { } + public void startPrefixMapping(String prefix, String uri) throws SAXException {} - public void endPrefixMapping(String prefix) - throws SAXException { } + public void endPrefixMapping(String prefix) throws SAXException {} - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { } + public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {} - public void processingInstruction(String target, String data) - throws SAXException { } + public void processingInstruction(String target, String data) throws SAXException {} - public void skippedEntity(String name) throws SAXException { } + public void skippedEntity(String name) throws SAXException {} - /////////////////////// Inner Classes /////////////////////// + /////////////////////// Inner Classes /////////////////////// /** - * Class that delegates all of the methods of a {@link - * DefaultHandler} to a {@link ManagedEntityConfigXmlParser} that - * implements all of the methods of <code>DefaultHandler</code>, but - * <B>is not</B> a <code>DefaultHandler</code>. + * Class that delegates all of the methods of a {@link DefaultHandler} to a + * {@link ManagedEntityConfigXmlParser} that implements all of the methods of + * <code>DefaultHandler</code>, but <B>is not</B> a <code>DefaultHandler</code>. */ static class DefaultHandlerDelegate extends DefaultHandler { - /** The <code>ManagedEntityConfigXmlParser</code> that does the - * real work */ + /** + * The <code>ManagedEntityConfigXmlParser</code> that does the real work + */ private ManagedEntityConfigXmlParser handler; /** - * Creates a new <code>DefaultHandlerDelegate</code> that - * delegates to the given + * Creates a new <code>DefaultHandlerDelegate</code> that delegates to the given * <code>ManagedEntityConfigXmlParser</code>. */ public DefaultHandlerDelegate(ManagedEntityConfigXmlParser handler) { @@ -535,9 +508,7 @@ public class ManagedEntityConfigXmlParser } @Override - public InputSource resolveEntity(String publicId, - String systemId) - throws SAXException { + public InputSource resolveEntity(String publicId, String systemId) throws SAXException { return handler.resolveEntity(publicId, systemId); } @@ -557,8 +528,7 @@ public class ManagedEntityConfigXmlParser } @Override - public void startPrefixMapping(String prefix, String uri) - throws SAXException { + public void startPrefixMapping(String prefix, String uri) throws SAXException { handler.startPrefixMapping(prefix, uri); } @@ -568,33 +538,28 @@ public class ManagedEntityConfigXmlParser } @Override - public void startElement(String uri, String localName, - String qName, Attributes attributes) - throws SAXException { + public void startElement(String uri, String localName, String qName, Attributes attributes) + throws SAXException { handler.startElement(uri, localName, qName, attributes); } @Override - public void endElement(String uri, String localName, String qName) - throws SAXException { + public void endElement(String uri, String localName, String qName) throws SAXException { handler.endElement(uri, localName, qName); } @Override - public void characters(char[] ch, int start, int length) - throws SAXException { + public void characters(char[] ch, int start, int length) throws SAXException { handler.characters(ch, start, length); } @Override - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { + public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { handler.ignorableWhitespace(ch, start, length); } @Override - public void processingInstruction(String target, String data) - throws SAXException { + public void processingInstruction(String target, String data) throws SAXException { handler.processingInstruction(target, data); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityController.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityController.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityController.java index c1a3fd1..77a3998 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityController.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityController.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; @@ -21,8 +19,7 @@ import org.apache.geode.admin.ManagedEntity; import org.apache.geode.admin.ManagedEntityConfig; /** - * Defines the actual administration (starting, stopping, etc.) of - * GemFire {@link ManagedEntity}s. + * Defines the actual administration (starting, stopping, etc.) of GemFire {@link ManagedEntity}s. * */ interface ManagedEntityController { @@ -40,34 +37,30 @@ interface ManagedEntityController { * Returns whether or not a managed entity is running */ public boolean isRunning(InternalManagedEntity entity); - + /** - * Returns the contents of a locator's log file. Other APIs are - * used to get the log file of managed entities that are also system - * members. + * Returns the contents of a locator's log file. Other APIs are used to get the log file of + * managed entities that are also system members. */ public String getLog(DistributionLocatorImpl locator); - + /** - * Returns the full path to the executable in - * <code>$GEMFIRE/bin</code> taking into account the {@linkplain - * ManagedEntityConfig#getProductDirectory product directory} and the - * platform's file separator. + * Returns the full path to the executable in <code>$GEMFIRE/bin</code> taking into account the + * {@linkplain ManagedEntityConfig#getProductDirectory product directory} and the platform's file + * separator. * * <P> * - * Note: we should probably do a better job of determine whether or - * not the machine on which the entity runs is Windows or Linux. + * Note: we should probably do a better job of determine whether or not the machine on which the + * entity runs is Windows or Linux. * - * @param executable - * The name of the executable that resides in - * <code>$GEMFIRE/bin</code>. + * @param executable The name of the executable that resides in <code>$GEMFIRE/bin</code>. */ public String getProductExecutable(InternalManagedEntity entity, String executable); - + /** - * Builds optional SSL command-line arguments. Returns null if SSL is not - * enabled for the distributed system. + * Builds optional SSL command-line arguments. Returns null if SSL is not enabled for the + * distributed system. */ public String buildSSLArguments(DistributedSystemConfig config); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityControllerFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityControllerFactory.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityControllerFactory.java index 372b2ed..faa67c5 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityControllerFactory.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedEntityControllerFactory.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; @@ -25,22 +23,26 @@ import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.logging.log4j.LogMarker; /** - * Creates ManagedEntityController for administration (starting, stopping, etc.) - * of GemFire {@link ManagedEntity}s. + * Creates ManagedEntityController for administration (starting, stopping, etc.) of GemFire + * {@link ManagedEntity}s. * */ public class ManagedEntityControllerFactory { private static final Logger logger = LogService.getLogger(); - - private static final String ENABLED_MANAGED_ENTITY_CONTROLLER_CLASS_NAME = "org.apache.geode.admin.internal.EnabledManagedEntityController"; - - static ManagedEntityController createManagedEntityController(final AdminDistributedSystem system) { + + private static final String ENABLED_MANAGED_ENTITY_CONTROLLER_CLASS_NAME = + "org.apache.geode.admin.internal.EnabledManagedEntityController"; + + static ManagedEntityController createManagedEntityController( + final AdminDistributedSystem system) { if (isEnabledManagedEntityController()) { - logger.info(LogMarker.CONFIG, "Local and remote OS command invocations are enabled for the Admin API."); + logger.info(LogMarker.CONFIG, + "Local and remote OS command invocations are enabled for the Admin API."); return createEnabledManagedEntityController(system); } else { - logger.info(LogMarker.CONFIG, "Local and remote OS command invocations are disabled for the Admin API."); + logger.info(LogMarker.CONFIG, + "Local and remote OS command invocations are disabled for the Admin API."); return new DisabledManagedEntityController(); } } @@ -53,8 +55,9 @@ public class ManagedEntityControllerFactory { return false; } } - - private static ManagedEntityController createEnabledManagedEntityController(final AdminDistributedSystem system) { + + private static ManagedEntityController createEnabledManagedEntityController( + final AdminDistributedSystem system) { return new EnabledManagedEntityController(system); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedSystemMemberImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedSystemMemberImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedSystemMemberImpl.java index f6ca2cc..02e7ae4 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedSystemMemberImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/ManagedSystemMemberImpl.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; @@ -24,50 +22,44 @@ import org.apache.geode.internal.admin.GemFireVM; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; /** - * A <code>SystemMember</code> that is also managed (or manageable) by - * the admin API. + * A <code>SystemMember</code> that is also managed (or manageable) by the admin API. * - * This class must be public so that its methods can be invoked - * reflectively (for MBean operations) on instances of its - * subclasses. + * This class must be public so that its methods can be invoked reflectively (for MBean operations) + * on instances of its subclasses. * * @since GemFire 4.0 */ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl - implements InternalManagedEntity { + implements InternalManagedEntity { /** Controller for starting and stopping local or remote managers */ protected ManagedEntityController controller; - + /** The state of this managed entity (see bug 32455) */ private int state = UNKNOWN; /** A lock that is obtained while this entity's state changes */ private final Object stateChange = new Object(); - ////////////////////// Constructors ////////////////////// + ////////////////////// Constructors ////////////////////// /** - * Creates a new <code>ManagedSystemMemberImpl</code> that - * represents an existing member of an + * Creates a new <code>ManagedSystemMemberImpl</code> that represents an existing member of an * <code>AdminDistributedSystem</code>. */ - protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, - GemFireVM vm) - throws AdminException { + protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, GemFireVM vm) + throws AdminException { super(system, vm); this.controller = system.getEntityController(); } /** - * Creates a new <code>ManagedSystemMemberImpl</code> that - * represents a non-existing member with the given - * <code>ManagedEntityConfig</code> that has not yet been started. + * Creates a new <code>ManagedSystemMemberImpl</code> that represents a non-existing member with + * the given <code>ManagedEntityConfig</code> that has not yet been started. */ - protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, - ManagedEntityConfig config) - throws AdminException { + protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, ManagedEntityConfig config) + throws AdminException { super(system); this.internalId = null; @@ -77,7 +69,7 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl this.controller = system.getEntityController(); } - ////////////////////// Instance Methods ////////////////////// + ////////////////////// Instance Methods ////////////////////// public String getWorkingDirectory() { return this.getEntityConfig().getWorkingDirectory(); @@ -107,24 +99,23 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl int oldState = this.state; this.state = state; return oldState; - + } else { synchronized (this.stateChange) { int oldState = this.state; this.state = state; this.stateChange.notifyAll(); - + return oldState; } } } /** - * Returns whether or not this managed system member needs to be - * stopped. If this member is stopped or is stopping, then it does - * not need to be stopped. Otherwise, it will atomically place this - * member in the {@link #STOPPING} state. See bug 32455. + * Returns whether or not this managed system member needs to be stopped. If this member is + * stopped or is stopping, then it does not need to be stopped. Otherwise, it will atomically + * place this member in the {@link #STOPPING} state. See bug 32455. */ protected boolean needToStop() { synchronized (this.stateChange) { @@ -139,11 +130,9 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl } /** - * Returns whether or not this managed system member needs to be - * started. If this member is started or is starting, then it - * does not need to be started. Otherwise, it will atomically - * place this member in the {@link #STARTING} state. See bug - * 32455. + * Returns whether or not this managed system member needs to be started. If this member is + * started or is starting, then it does not need to be started. Otherwise, it will atomically + * place this member in the {@link #STARTING} state. See bug 32455. */ protected boolean needToStart() { synchronized (this.stateChange) { @@ -158,8 +147,8 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl } /** - * Sets the state of this managed system member depending on whether - * or not <code>vm</code> is <code>null</code>. + * Sets the state of this managed system member depending on whether or not <code>vm</code> is + * <code>null</code>. */ @Override void setGemFireVM(GemFireVM vm) throws AdminException { @@ -175,11 +164,11 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl /** * Waits until this system member's "state" is {@link #RUNNING}. */ - public boolean waitToStart(long timeout) - throws InterruptedException { + public boolean waitToStart(long timeout) throws InterruptedException { + + if (Thread.interrupted()) + throw new InterruptedException(); - if (Thread.interrupted()) throw new InterruptedException(); - long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < timeout) { synchronized (this.stateChange) { @@ -200,10 +189,10 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl /** * Waits until this system member's "state" is {@link #STOPPED}. */ - public boolean waitToStop(long timeout) - throws InterruptedException { + public boolean waitToStop(long timeout) throws InterruptedException { - if (Thread.interrupted()) throw new InterruptedException(); + if (Thread.interrupted()) + throw new InterruptedException(); long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < timeout) { synchronized (this.stateChange) { @@ -222,9 +211,8 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl } /** - * Appends configuration information to a <code>StringBuffer</code> - * that contains a command line. Handles certain configuration - * parameters specially. + * Appends configuration information to a <code>StringBuffer</code> that contains a command line. + * Handles certain configuration parameters specially. */ protected void appendConfiguration(StringBuffer sb) { ConfigurationParameter[] params = this.getConfiguration(); @@ -241,15 +229,14 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl if (value != null && !value.equals("")) { if (name.equals(LOCATORS)) { // Use the new locator syntax so that is plays nicely with - // rsh. See bug 32306. + // rsh. See bug 32306. String locator = value; int firstBracket = locator.indexOf('['); int lastBracket = locator.indexOf(']'); if (firstBracket > -1 && lastBracket > -1) { String host = locator.substring(0, firstBracket); - String port = - locator.substring(firstBracket + 1, lastBracket); + String port = locator.substring(firstBracket + 1, lastBracket); locator = host + ":" + port; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/MemberHealthConfigImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/MemberHealthConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/MemberHealthConfigImpl.java index e58e975..f250fee 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/MemberHealthConfigImpl.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/MemberHealthConfigImpl.java @@ -1,65 +1,65 @@ /* - * 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; import org.apache.geode.admin.*; // @todo Make this class (and all of its subclasses) {@link java.io.Externalizable} or -// {@link org.apache.geode.DataSerializable}. +// {@link org.apache.geode.DataSerializable}. /** * The implementation of <code>MemberHealthConfig</code> * * * @since GemFire 3.5 */ -public abstract class MemberHealthConfigImpl - implements MemberHealthConfig, java.io.Serializable { +public abstract class MemberHealthConfigImpl implements MemberHealthConfig, java.io.Serializable { private static final long serialVersionUID = 3966032573073580490L; - - /** The maximum process size (in megabytes) of a healthy member of - * the distributed system. */ + + /** + * The maximum process size (in megabytes) of a healthy member of the distributed system. + */ private long maxVMProcessSize = DEFAULT_MAX_VM_PROCESS_SIZE; - /** The maximum number of enqueued incoming or outgoing - * messages that a healthy member of a distributed system can - * have. */ + /** + * The maximum number of enqueued incoming or outgoing messages that a healthy member of a + * distributed system can have. + */ private long maxMessageQueueSize = DEFAULT_MAX_MESSAGE_QUEUE_SIZE; - /** The maximum number message replies that can timeout in a healthy - * member. */ + /** + * The maximum number message replies that can timeout in a healthy member. + */ private long maxReplyTimeouts = DEFAULT_MAX_REPLY_TIMEOUTS; - /** The maximum multicast retransmit / multicast message count ratio + /** + * The maximum multicast retransmit / multicast message count ratio */ private double maxRetransmissionRatio = DEFAULT_MAX_RETRANSMISSION_RATIO; - /////////////////////// Constructors /////////////////////// + /////////////////////// Constructors /////////////////////// /** - * Creates a new <code>MemberHealthConfigImpl</code> with the - * default configuration. + * Creates a new <code>MemberHealthConfigImpl</code> with the default configuration. */ MemberHealthConfigImpl() { } - ///////////////////// Instance Methods ////////////////////// + ///////////////////// Instance Methods ////////////////////// public long getMaxVMProcessSize() { return this.maxVMProcessSize;