http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberCacheServer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberCacheServer.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberCacheServer.java new file mode 100755 index 0000000..ba31538 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberCacheServer.java @@ -0,0 +1,308 @@ +/* + * 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 + * + * 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.internal.admin.api; + +import org.apache.geode.cache.server.ServerLoadProbe; + +/** + * Administrative interface that represents a {@link org.apache.geode.cache.server.CacheServer + * CacheServer} that serves the contents of a system member's cache to clients. + * + * @see SystemMemberCache#addCacheServer + * + * @since GemFire 5.7 + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public interface SystemMemberCacheServer { + + /** + * Returns the port on which this cache server listens for clients to connect. + */ + public int getPort(); + + /** + * Sets the port on which this cache server listens for clients to connect. + * + * @throws AdminException If this cache server is running + */ + public void setPort(int port) throws AdminException; + + /** + * Starts this cache server. Once the server is running, its configuration cannot be changed. + * + * @throws AdminException If an error occurs while starting the cache server + */ + public void start() throws AdminException; + + /** + * Returns whether or not this cache server is running + */ + public boolean isRunning(); + + /** + * Stops this cache server. Note that the <code>CacheServer</code> can be reconfigured and + * restarted if desired. + */ + public void stop() throws AdminException; + + /** + * Updates the information about this cache server. + */ + public void refresh(); + + /** + * Returns a string representing the ip address or host name that this server will listen on. + * + * @return the ip address or host name that this server is to listen on + * @since GemFire 5.7 + */ + public String getBindAddress(); + + /** + * Sets the ip address or host name that this server is to listen on for client connections. + * <p> + * Setting a specific bind address will cause the cache server to always use this address and + * ignore any address specified by "server-bind-address" or "bind-address" in the + * <code>gemfire.properties</code> file (see + * {@link org.apache.geode.distributed.DistributedSystem} for a description of these properties). + * <p> + * A <code>null</code> value will be treated the same as the default "". + * <p> + * The default value does not override the gemfire.properties. If you wish to override the + * properties and want to have your server bind to all local addresses then use this string + * <code>"0.0.0.0"</code>. + * + * @param address the ip address or host name that this server is to listen on + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setBindAddress(String address) throws AdminException; + + /** + * Returns a string representing the ip address or host name that server locators will tell + * clients that this server is listening on. + * + * @return the ip address or host name to give to clients so they can connect to this server + * @since GemFire 5.7 + */ + public String getHostnameForClients(); + + /** + * Sets the ip address or host name that this server is to listen on for client connections. + * <p> + * Setting a specific hostname-for-clients will cause server locators to use this value when + * telling clients how to connect to this server. + * <p> + * The default value causes the bind-address to be given to clients + * <p> + * A <code>null</code> value will be treated the same as the default "". + * + * @param name the ip address or host name that will be given to clients so they can connect to + * this server + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setHostnameForClients(String name) throws AdminException; + + /** + * Sets whether or not this cache server should notify clients based on key subscription. + * + * If false, then an update to any key on the server causes an update to be sent to all clients. + * This update does not push the actual data to the clients. Instead, it causes the client to + * locally invalidate or destroy the corresponding entry. The next time the client requests the + * key, it goes to the cache server for the value. + * + * If true, then an update to any key on the server causes an update to be sent to only those + * clients who have registered interest in that key. Other clients are not notified of the change. + * In addition, the actual value is pushed to the client. The client does not need to request the + * new value from the cache server. + * + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setNotifyBySubscription(boolean b) throws AdminException; + + /** + * Answers whether or not this cache server should notify clients based on key subscription. + * + * @since GemFire 5.7 + */ + public boolean getNotifyBySubscription(); + + /** + * Sets the buffer size in bytes of the socket connection for this <code>CacheServer</code>. The + * default is 32768 bytes. + * + * @param socketBufferSize The size in bytes of the socket buffer + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setSocketBufferSize(int socketBufferSize) throws AdminException; + + /** + * Returns the configured buffer size of the socket connection for this <code>CacheServer</code>. + * The default is 32768 bytes. + * + * @return the configured buffer size of the socket connection for this <code>CacheServer</code> + * @since GemFire 5.7 + */ + public int getSocketBufferSize(); + + /** + * Sets the maximum amount of time between client pings. This value is used by the + * <code>ClientHealthMonitor</code> to determine the health of this <code>CacheServer</code>'s + * clients. The default is 60000 ms. + * + * @param maximumTimeBetweenPings The maximum amount of time between client pings + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setMaximumTimeBetweenPings(int maximumTimeBetweenPings) throws AdminException; + + /** + * Returns the maximum amount of time between client pings. This value is used by the + * <code>ClientHealthMonitor</code> to determine the health of this <code>CacheServer</code>'s + * clients. The default is 60000 ms. + * + * @return the maximum amount of time between client pings. + * @since GemFire 5.7 + */ + public int getMaximumTimeBetweenPings(); + + /** + * Returns the maximum allowed client connections + * + * @since GemFire 5.7 + */ + public int getMaxConnections(); + + /** + * Sets the maxium number of client connections allowed. When the maximum is reached the server + * will stop accepting connections. + * + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setMaxConnections(int maxCons) throws AdminException; + + /** + * Returns the maxium number of threads allowed in this server to service client requests. The + * default of <code>0</code> causes the server to dedicate a thread for every client connection. + * + * @since GemFire 5.7 + */ + public int getMaxThreads(); + + /** + * Sets the maxium number of threads allowed in this server to service client requests. The + * default of <code>0</code> causes the server to dedicate a thread for every client connection. + * + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setMaxThreads(int maxThreads) throws AdminException; + + /** + * Returns the maximum number of messages that can be enqueued in a client-queue. + * + * @since GemFire 5.7 + */ + public int getMaximumMessageCount(); + + /** + * Sets maximum number of messages that can be enqueued in a client-queue. + * + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setMaximumMessageCount(int maxMessageCount) throws AdminException; + + /** + * Returns the time (in seconds ) after which a message in the client queue will expire. + * + * @since GemFire 5.7 + */ + public int getMessageTimeToLive(); + + /** + * Sets the time (in seconds ) after which a message in the client queue will expire. + * + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setMessageTimeToLive(int messageTimeToLive) throws AdminException; + + /** + * Sets the list of server groups this cache server will belong to. By default cache servers + * belong to the default global server group which all cache servers always belong to. + * + * @param groups possibly empty array of <code>String</code> where each string is a server groups + * that this cache server will be a member of. + * @throws AdminException if this cache server is running + * @since GemFire 5.7 + */ + public void setGroups(String[] groups) throws AdminException; + + /** + * Returns the list of server groups that this cache server belongs to. + * + * @return a possibly empty array of <code>String</code>s where each string is a server group. + * Modifying this array will not change the server groups that this cache server belongs + * to. + * @since GemFire 5.7 + */ + public String[] getGroups(); + + /** + * Get a description of the load probe for this cache server. {@link ServerLoadProbe} for details + * on the load probe. + * + * @return the load probe used by this cache server. + * @since GemFire 5.7 + */ + public String getLoadProbe(); + + /** + * Set the load probe for this cache server. See {@link ServerLoadProbe} for details on how to + * implement a load probe. + * + * The load probe should implement DataSerializable if it is used with this interface, because it + * will be sent to the remote VM. + * + * @param loadProbe the load probe to use for this cache server. + * @throws AdminException if the cache server is running + * @since GemFire 5.7 + */ + public void setLoadProbe(ServerLoadProbe loadProbe) throws AdminException; + + /** + * Get the frequency in milliseconds to poll the load probe on this cache server. + * + * @return the frequency in milliseconds that we will poll the load probe. + */ + public long getLoadPollInterval(); + + /** + * Set the frequency in milliseconds to poll the load probe on this cache server + * + * @param loadPollInterval the frequency in milliseconds to poll the load probe. Must be greater + * than 0. + * @throws AdminException if the cache server is running + */ + public void setLoadPollInterval(long loadPollInterval) throws AdminException; + +}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegion.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegion.java new file mode 100644 index 0000000..fb5430d --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegion.java @@ -0,0 +1,314 @@ +/* + * 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 + * + * 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.internal.admin.api; + +import org.apache.geode.cache.*; +import java.io.File; + +/** + * Administrative interface that represent's the {@link SystemMember}'s view of one of its cache's + * {@link org.apache.geode.cache.Region}s. If the region in the remote system member is closed or + * destroyed, the methods of <code>SystemMemberRegion</code> will throw + * {@link RegionNotFoundException}. + * + * @since GemFire 3.5 + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public interface SystemMemberRegion { + // attributes + /** + * Returns the name that identifies this region in its cache. + * + * @see org.apache.geode.cache.Region#getName + */ + public String getName(); + + /** + * Returns the full path name that identifies this region in its cache. + * + * @see org.apache.geode.cache.Region#getFullPath + */ + public String getFullPath(); + + /** + * Returns the names of all the subregions of this region. + */ + public java.util.Set getSubregionNames(); + + /** + * Returns the full path of each of the subregions of this region. These paths are suitable for + * use with {@link SystemMemberCache#getRegion}. + */ + public java.util.Set getSubregionFullPaths(); + + /** + * Returns a description of any user attribute associated with this region. The description + * includes the classname of the user attribute object as well as its <code>toString</code> + * representation. + */ + public String getUserAttribute(); + + /** + * Returns a description of any CacheLoader associated with this region. + */ + public String getCacheLoader(); + + /** + * Returns a description of any CacheWriter associated with this region. + */ + public String getCacheWriter(); + + /** + * Returns the <code>EvictionAttributes</code> that configure how entries in the the region are + * evicted + */ + public EvictionAttributes getEvictionAttributes(); + + /** + * Returns a description of the CacheListener in this region's attributes. If there is more than 1 + * CacheListener defined for a region this method will return the description of the 1st + * CacheListener returned from {@link #getCacheListeners} + * + * @deprecated as of 6.0 use getCacheListeners() instead + */ + @Deprecated + public String getCacheListener(); + + /** + * This method will return an empty array if there are no CacheListeners defined on the region. If + * there are one or more than 1 CacheListeners defined, this method will return an array which has + * the names of all the CacheListeners + * + * @return String[] the region's <code>CacheListeners</code> as a String array + * @since GemFire 6.0 + */ + public String[] getCacheListeners(); + + /** + * Returns the KeyConstraint in this region's attributes. + */ + public String getKeyConstraint(); + + /** + * Returns the ValueConstraint in this region's attributes. + */ + public String getValueConstraint(); + + /** + * Returns the RegionTimeToLive time limit in this region's attributes. + */ + public int getRegionTimeToLiveTimeLimit(); + + /** + * Returns the RegionTimeToLive action in this region's attributes. + */ + public ExpirationAction getRegionTimeToLiveAction(); + + /** + * Returns the EntryTimeToLive time limit in this region's attributes. + */ + public int getEntryTimeToLiveTimeLimit(); + + /** + * Returns the EntryTimeToLive action in this region's attributes. + */ + public ExpirationAction getEntryTimeToLiveAction(); + + /** + * string describing the CustomExpiry for entry-time-to-live + * + * @return the CustomExpiry for entry-time-to-live + */ + public String getCustomEntryTimeToLive(); + + /** + * Returns the RegionIdleTimeout time limit in this region's attributes. + */ + public int getRegionIdleTimeoutTimeLimit(); + + /** + * Returns the RegionIdleTimeout action in this region's attributes. + */ + public ExpirationAction getRegionIdleTimeoutAction(); + + /** + * Returns the EntryIdleTimeout time limit in this region's attributes. + */ + public int getEntryIdleTimeoutTimeLimit(); + + /** + * Returns the EntryIdleTimeout action in this region's attributes. + */ + public ExpirationAction getEntryIdleTimeoutAction(); + + /** + * string describing the CustomExpiry for entry-idle-timeout + * + * @return the CustomExpiry for entry-idle-timeout + */ + public String getCustomEntryIdleTimeout(); + + /** + * Returns the MirrorType in this region's attributes. + * + * @deprecated as of 5.0, you should use getDataPolicy instead + */ + @Deprecated + public MirrorType getMirrorType(); + + /** + * Returns the DataPolicy in this region's attributes. + */ + public DataPolicy getDataPolicy(); + + /** + * + * /** Returns the Scope in this region's attributes. + */ + public Scope getScope(); + + /** + * Returns the InitialCapacity in this region's attributes. + */ + public int getInitialCapacity(); + + /** + * Returns the LoadFactor in this region's attributes. + */ + public float getLoadFactor(); + + /** + * Returns the ConcurrencyLevel in this region's attributes. + */ + public int getConcurrencyLevel(); + + /** + * Returns whether or not conflicting concurrent operations on this region are prevented + */ + public boolean getConcurrencyChecksEnabled(); + + /** + * Returns the StatisticsEnabled in this region's attributes. + */ + public boolean getStatisticsEnabled(); + + /** + * Returns whether or not a persistent backup should be made of the region (as opposed to just + * writing the overflow data to disk). + */ + public boolean getPersistBackup(); + + /** + * Returns the <code>DiskWriteAttributes</code> that configure how the region is written to disk. + */ + public DiskWriteAttributes getDiskWriteAttributes(); + + /** + * Returns the directories to which the region's data are written. If multiple directories are + * used, GemFire will attempt to distribute the data evenly amongst them. + */ + public File[] getDiskDirs(); + + /** + * Returns the number of entries currently in this region. + */ + public int getEntryCount(); + + /** + * Returns the number of subregions currently in this region. + */ + public int getSubregionCount(); + + /** + * Returns the LastModifiedTime obtained from this region's statistics. + */ + public long getLastModifiedTime(); + + /** + * Returns the LastAccessedTime obtained from this region's statistics. + */ + public long getLastAccessedTime(); + + /** + * Returns the HitCount obtained from this region's statistics. + */ + public long getHitCount(); + + /** + * Returns the MissCount obtained from this region's statistics. + */ + public long getMissCount(); + + /** + * Returns the HitRatio obtained from this region's statistics. + */ + public float getHitRatio(); + + /** + * Returns whether or not acks are sent after an update is processed. + * + * @return False if acks are sent after updates are processed; true if acks are sent before + * updates are processed. + * + * @since GemFire 4.1 + */ + public boolean getEarlyAck(); + + // operations + /** + * Updates the state of this region instance. Note that once a cache instance is closed refresh + * will never change the state of its regions. + */ + public void refresh(); + + /** + * Creates a subregion of this region. + * + * @param name The name of the region to create + * @param attrs The attributes of the root region + * + * @throws AdminException If the region cannot be created + * + * @since GemFire 4.0 + */ + public SystemMemberRegion createSubregion(String name, RegionAttributes attrs) + throws AdminException; + + /** + * Returns the <code>MembershipAttributes</code> that configure required roles for reliable access + * to the region. + * + * @deprecated this API is scheduled to be removed + */ + public MembershipAttributes getMembershipAttributes(); + + /** + * Returns the <code>SubscriptionAttributes</code> for the region. + * + * @since GemFire 5.0 + */ + public SubscriptionAttributes getSubscriptionAttributes(); + + /** + * Returns the <code>PartitionAttributes</code> for the region. + * + * @since GemFire 5.7 + */ + public PartitionAttributes getPartitionAttributes(); + +} + http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegionEvent.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegionEvent.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegionEvent.java new file mode 100644 index 0000000..6921392 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberRegionEvent.java @@ -0,0 +1,31 @@ +/* + * 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 + * + * 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.internal.admin.api; + +/** + * An event that describes an operation on a region. Instances of this are delivered to a + * {@link SystemMemberCacheListener} when a a region comes or goes. + * + * @since GemFire 5.0 + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public interface SystemMemberRegionEvent extends SystemMemberCacheEvent { + /** + * Returns the full path of the region the event was done on. + */ + public String getRegionPath(); +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberType.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberType.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberType.java new file mode 100755 index 0000000..775ea9f --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMemberType.java @@ -0,0 +1,150 @@ +/* + * 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 + * + * 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.internal.admin.api; + +// import java.io.*; + +/** + * Type-safe definition for system members. + * + * @since GemFire 3.5 + * + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public class SystemMemberType implements java.io.Serializable { + private static final long serialVersionUID = 3284366994485749302L; + + /** GemFire shared-memory manager connected to the distributed system */ + public static final SystemMemberType MANAGER = new SystemMemberType("GemFireManager"); + + /** Application connected to the distributed system */ + public static final SystemMemberType APPLICATION = new SystemMemberType("Application"); + + /** GemFire Cache VM connected to the distributed system */ + public static final SystemMemberType CACHE_VM = new SystemMemberType("CacheVm"); + + /** + * GemFire Cache Server connected to the distributed system + * + * @deprecated as of 5.7 use {@link #CACHE_VM} instead. + */ + @Deprecated + public static final SystemMemberType CACHE_SERVER = CACHE_VM; + + + /** The display-friendly name of this system member type. */ + private final transient String name; + + // The 4 declarations below are necessary for serialization + /** int used as ordinal to represent this Scope */ + public final int ordinal = nextOrdinal++; + + private static int nextOrdinal = 0; + + private static final SystemMemberType[] VALUES = {MANAGER, APPLICATION, CACHE_VM}; + + private Object readResolve() throws java.io.ObjectStreamException { + return VALUES[ordinal]; // Canonicalize + } + + /** Creates a new instance of SystemMemberType. */ + private SystemMemberType(String name) { + this.name = name; + } + + /** Return the SystemMemberType represented by specified ordinal */ + public static SystemMemberType fromOrdinal(int ordinal) { + return VALUES[ordinal]; + } + + public String getName() { + return this.name; + } + + /** Return whether this is <code>MANAGER</code>. */ + public boolean isManager() { + return this.equals(MANAGER); + } + + /** Return whether this is <code>APPLICATION</code>. */ + public boolean isApplication() { + return this.equals(APPLICATION); + } + + /** + * Return whether this is <code>CACHE_SERVER</code>. + * + * @deprecated as of 5.7 use {@link #isCacheVm} instead. + */ + @Deprecated + public boolean isCacheServer() { + return isCacheVm(); + } + + /** + * Return whether this is <code>CACHE_VM</code>. + */ + public boolean isCacheVm() { + return this.equals(CACHE_VM); + } + + /** + * Returns a string representation for this system member type. + * + * @return the name of this system member type + */ + @Override + public String toString() { + return this.name; + } + + /** + * Indicates whether some other object is "equal to" this one. + * + * @param other the reference object with which to compare. + * @return true if this object is the same as the obj argument; false otherwise. + */ + @Override + public boolean equals(Object other) { + if (other == this) + return true; + if (other == null) + return false; + if (!(other instanceof SystemMemberType)) + return false; + final SystemMemberType that = (SystemMemberType) other; + if (this.ordinal != that.ordinal) + return false; + return true; + } + + /** + * Returns a hash code for the object. This method is supported for the benefit of hashtables such + * as those provided by java.util.Hashtable. + * + * @return the integer 0 if description is null; otherwise a unique integer. + */ + @Override + public int hashCode() { + int result = 17; + final int mult = 37; + result = mult * result + this.ordinal; + return result; + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipEvent.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipEvent.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipEvent.java new file mode 100644 index 0000000..4507e96 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipEvent.java @@ -0,0 +1,42 @@ +/* + * 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 + * + * 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.internal.admin.api; + +import org.apache.geode.distributed.DistributedMember; + +/** + * An event that describes the distributed member originated this event. Instances of this are + * delivered to a {@link SystemMembershipListener} when a member has joined or left the distributed + * system. + * + * @since GemFire 3.5 + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public interface SystemMembershipEvent { + /** + * Returns the distributed member as a String. + */ + public String getMemberId(); + + /** + * Returns the {@link DistributedMember} that this event originated in. + * + * @return the member that performed the operation that originated this event. + * @since GemFire 5.0 + */ + public DistributedMember getDistributedMember(); +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipListener.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipListener.java new file mode 100644 index 0000000..60720ac --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/SystemMembershipListener.java @@ -0,0 +1,59 @@ +/* + * 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 + * + * 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.internal.admin.api; + +/** + * A listener whose callback methods are invoked when members join or leave the GemFire distributed + * system. + * + * @see AdminDistributedSystem#addMembershipListener + * + * @since GemFire 3.5 + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public interface SystemMembershipListener { + + /** + * Invoked when a member has joined the distributed system + */ + public void memberJoined(SystemMembershipEvent event); + + /** + * Invoked when a member has gracefully left the distributed system. This occurs when the member + * took action to remove itself from the distributed system. + */ + public void memberLeft(SystemMembershipEvent event); + + /** + * Invoked when a member has unexpectedly left the distributed system. This occurs when a member + * is forcibly removed from the distributed system by another process, such as from <a + * href=../distributed/DistributedSystem.html#member-timeout> failure detection</a>, or <a + * href=../distributed/DistributedSystem.html#enable-network-partition-detection> network + * partition detection</a> processing. + */ + public void memberCrashed(SystemMembershipEvent event); + + // /** + // * Invoked when a member broadcasts an informational message. + // * + // * @see org.apache.geode.distributed.DistributedSystem#fireInfoEvent + // * + // * @since GemFire 4.0 + // */ + // public void memberInfo(SystemMembershipEvent event); + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/UnmodifiableConfigurationException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/UnmodifiableConfigurationException.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/UnmodifiableConfigurationException.java new file mode 100755 index 0000000..5634c09 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/UnmodifiableConfigurationException.java @@ -0,0 +1,81 @@ +/* + * 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 + * + * 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.internal.admin.api; + +/** + * An <code>UnmodifiableConfigurationException</code> is thrown when an attempt is made to modify + * the value of an unmodifiable {@link ConfigurationParameter}. + * + * @since GemFire 3.5 + * + * @deprecated as of 7.0 use the <code><a href= + * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> + * package instead + */ +public class UnmodifiableConfigurationException extends AdminException { + private static final long serialVersionUID = -7653547392992060646L; + + /** + * Constructs a new exception with <code>null</code> as its detail message. The cause is not + * initialized, and may subsequently be initialized by a call to {@link Throwable#initCause}. + */ + public UnmodifiableConfigurationException() { + super(); + } + + /** + * Constructs a new exception with the specified detail message. The cause is not initialized, and + * may subsequently be initialized by a call to {@link Throwable#initCause}. + * + * @param message the detail message. The detail message is saved for later retrieval by the + * {@link #getMessage()} method. + */ + public UnmodifiableConfigurationException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * <p> + * Note that the detail message associated with <code>cause</code> is <i>not</i> automatically + * incorporated in this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the + * {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). + * (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public UnmodifiableConfigurationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of + * <tt>(cause==null ? null : cause.toString())</tt> (which typically contains the class and detail + * message of <tt>cause</tt>). This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). + * (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public UnmodifiableConfigurationException(Throwable cause) { + super(cause); + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/895fd144/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/AbstractHealthEvaluator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/AbstractHealthEvaluator.java b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/AbstractHealthEvaluator.java new file mode 100644 index 0000000..983c834 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/AbstractHealthEvaluator.java @@ -0,0 +1,170 @@ +/* + * 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 + * + * 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.internal.admin.api.impl; + +import java.util.List; + +import org.apache.logging.log4j.Logger; + +import org.apache.geode.internal.admin.api.GemFireHealth; +import org.apache.geode.internal.admin.api.GemFireHealthConfig; +import org.apache.geode.distributed.internal.DM; +import org.apache.geode.internal.i18n.LocalizedStrings; +import org.apache.geode.internal.logging.LogService; +import org.apache.geode.internal.logging.log4j.LocalizedMessage; + +/** + * The abstract superclass of all GemFire health evaluators. Basically, this class specifies what + * the health evaluators need and what they should do. + * + * <P> + * + * Note that evaluators never reside in the administration VM, they only in member VMs. They are not + * <code>Serializable</code> and aren't meant to be. + * + * + * @since GemFire 3.5 + */ +public abstract class AbstractHealthEvaluator { + + private static final Logger logger = LogService.getLogger(); + + /** + * The number of times this evaluator has been evaluated. Certain checks are not made the first + * time an evaluation occurs. + */ + private int numEvaluations; + + ////////////////////// Constructors ////////////////////// + + /** + * Creates a new <code>AbstractHealthEvaluator</code> with the given + * <code>GemFireHealthConfig</code> and <code>DistributionManager</code>. + * + * Originally, this method took an <code>InternalDistributedSystem</code>, but we found there were + * race conditions during initialization. Namely, that a <code>DistributionMessage</code> can be + * processed before the <code>InternalDistributedSystem</code>'s <code>DistributionManager</code> + * is set. + */ + protected AbstractHealthEvaluator(GemFireHealthConfig config, DM dm) { + this.numEvaluations = 0; + } + + ///////////////////// Instance Methods ///////////////////// + + /** + * Evaluates the health of a component of a GemFire distributed system. + * + * @param status A list of {@link AbstractHealthEvaluator.HealthStatus HealthStatus} objects that + * is populated when ill health is detected. + */ + public final void evaluate(List status) { + this.numEvaluations++; + check(status); + } + + /** + * Checks the health of a component of a GemFire distributed system. + * + * @see #evaluate + */ + protected abstract void check(List status); + + /** + * Returns whether or not this is the first evaluation + */ + protected final boolean isFirstEvaluation() { + return this.numEvaluations <= 1; + } + + /** + * A factory method that creates a {@link AbstractHealthEvaluator.HealthStatus HealthStats} with + * {@linkplain GemFireHealth#OKAY_HEALTH okay} status. + */ + protected HealthStatus okayHealth(String diagnosis) { + logger.info(LocalizedMessage.create(LocalizedStrings.AbstractHealthEvaluator_OKAY_HEALTH__0, + diagnosis)); + return new HealthStatus(GemFireHealth.OKAY_HEALTH, diagnosis); + } + + /** + * A factory method that creates a {@link AbstractHealthEvaluator.HealthStatus HealthStats} with + * {@linkplain GemFireHealth#POOR_HEALTH poor} status. + */ + protected HealthStatus poorHealth(String diagnosis) { + logger.info(LocalizedMessage.create(LocalizedStrings.AbstractHealthEvaluator_POOR_HEALTH__0, + diagnosis)); + return new HealthStatus(GemFireHealth.POOR_HEALTH, diagnosis); + } + + /** + * Returns a <code>String</code> describing the component whose health is evaluated by this + * evaluator. + */ + protected abstract String getDescription(); + + /** + * Closes this evaluator and releases all of its resources + */ + abstract void close(); + + /////////////////////// Inner Classes ////////////////////// + + /** + * Represents the health of a GemFire component. + */ + public class HealthStatus { + /** The health of a GemFire component */ + private GemFireHealth.Health healthCode; + + /** The diagnosis of the illness */ + private String diagnosis; + + ////////////////////// Constructors ////////////////////// + + /** + * Creates a new <code>HealthStatus</code> with the give <code>health</code> code and + * <code>dianosis</code> message. + * + * @see GemFireHealth#OKAY_HEALTH + * @see GemFireHealth#POOR_HEALTH + */ + HealthStatus(GemFireHealth.Health healthCode, String diagnosis) { + this.healthCode = healthCode; + this.diagnosis = "[" + AbstractHealthEvaluator.this.getDescription() + "] " + diagnosis; + } + + ///////////////////// Instance Methods ///////////////////// + + /** + * Returns the health code + * + * @see GemFireHealth#OKAY_HEALTH + * @see GemFireHealth#POOR_HEALTH + */ + public GemFireHealth.Health getHealthCode() { + return this.healthCode; + } + + /** + * Returns the diagnosis prepended with a description of the component that is ill. + */ + public String getDiagnosis() { + return this.diagnosis; + } + + } + +}
