[25/50] [abbrv] incubator-geode git commit: GEODE-288: move admin packages to internal

2016-11-15 Thread klund
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6c305f8/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthConfigImpl.java
--
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthConfigImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthConfigImpl.java
new file mode 100644
index 000..d38d5cb
--- /dev/null
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthConfigImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.geode.internal.admin.api.DistributedSystemHealthConfig;
+
+/**
+ * The implementation of DistributedSystemHealthConfig. Note that 
because it never
+ * leaves the management VM, it is not Serializable and is not 
part of the
+ * {@link GemFireHealthConfigImpl} class hierarchy.
+ *
+ *
+ * @since GemFire 3.5
+ */
+public class DistributedSystemHealthConfigImpl implements 
DistributedSystemHealthConfig {
+
+  /**
+   * The maximum number of application members that can unexceptedly leave a 
healthy the distributed
+   * system.
+   */
+  private long maxDepartedApplications = DEFAULT_MAX_DEPARTED_APPLICATIONS;
+
+  // Constructors //
+
+  /**
+   * Creates a new DistributedSystemHealthConfigImpl with the 
default configuration.
+   */
+  protected DistributedSystemHealthConfigImpl() {
+
+  }
+
+  / Instance Methods /
+
+  public long getMaxDepartedApplications() {
+return this.maxDepartedApplications;
+  }
+
+  public void setMaxDepartedApplications(long maxDepartedApplications) {
+this.maxDepartedApplications = maxDepartedApplications;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6c305f8/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthEvaluator.java
--
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthEvaluator.java
 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthEvaluator.java
new file mode 100644
index 000..5087933
--- /dev/null
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/DistributedSystemHealthEvaluator.java
@@ -0,0 +1,167 @@
+/*
+ * 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 org.apache.geode.internal.admin.api.DistributedSystemHealthConfig;
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.MembershipListener;
+import 
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Contains the logic for evaluating the health of an entire GemFire 
distributed system according to
+ * the thresholds provided in a {@link DistributedSystemHealthConfig}.
+ *
+ * 
+ *
+ * Note that unlike other evaluators, the 
DistributedSystemHealthEvaluator 

[25/50] [abbrv] incubator-geode git commit: GEODE-288: move admin packages to internal

2016-11-07 Thread klund
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6bb27bf1/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/GemFireHealthImpl.java
--
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/GemFireHealthImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/GemFireHealthImpl.java
new file mode 100644
index 000..fc40261
--- /dev/null
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/GemFireHealthImpl.java
@@ -0,0 +1,514 @@
+/*
+ * 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 org.apache.geode.CancelException;
+import org.apache.geode.internal.Assert;
+import org.apache.geode.internal.admin.*;
+import org.apache.geode.internal.admin.api.AdminDistributedSystem;
+import org.apache.geode.internal.admin.api.DistributedSystemHealthConfig;
+import org.apache.geode.internal.admin.api.GemFireHealth;
+import org.apache.geode.internal.admin.api.GemFireHealthConfig;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+
+/**
+ * Provides the implementation of the GemFireHealth 
administration API. This class is
+ * responsible for {@linkplain GemFireVM#addHealthListener sending} the {@link 
GemFireHealthConfig}s
+ * to the remote member VM in which the health is calcualted.
+ *
+ *
+ * @since GemFire 3.5
+ */
+public class GemFireHealthImpl implements GemFireHealth, JoinLeaveListener, 
HealthListener {
+
+  /** The distributed system whose health is being monitored */
+  private final GfManagerAgent agent;
+
+  /** The default configuration for checking GemFire health */
+  protected GemFireHealthConfig defaultConfig;
+
+  /**
+   * Maps the name of a host to its GemFireHealthConfig. Note 
that the mappings are
+   * created lazily.
+   */
+  private final Map hostConfigs;
+
+  /**
+   * Maps the name of a host to all of the members (GemFireVMs) 
that run on that host.
+   */
+  private final Map hostMembers;
+
+  /** The members that are known to be in {@link #OKAY_HEALTH}. */
+  private Collection okayHealth;
+
+  /** The members that are known to be in {@link #POOR_HEALTH}. */
+  private Collection poorHealth;
+
+  /** The overall health of GemFire */
+  private GemFireHealth.Health overallHealth;
+
+  /** Is this GemFireHealthImpl closed? */
+  private boolean isClosed;
+
+  /**
+   * The configuration specifying how the health of the distributed system 
should be computed.
+   */
+  protected volatile DistributedSystemHealthConfig dsHealthConfig;
+
+  /** Monitors the health of the entire distributed system */
+  private DistributedSystemHealthMonitor dsHealthMonitor = null;
+
+  /**
+   * The distributed system whose health is monitored by this 
GemFireHealth.
+   */
+  private final AdminDistributedSystem system;
+
+
+  /// Constructors ///
+
+  /**
+   * Creates a new GemFireHealthImpl that monitors the health of 
member of the given
+   * distributed system.
+   */
+  protected GemFireHealthImpl(GfManagerAgent agent, AdminDistributedSystem 
system) {
+// agent.getDM().getLogger().info("Creating GemFireHealthImpl",
+// new Exception("Stack trace"));
+
+this.agent = agent;
+this.system = system;
+
+this.hostConfigs = new HashMap();
+this.hostMembers = new HashMap();
+this.okayHealth = new HashSet();
+this.poorHealth = new HashSet();
+this.overallHealth = GOOD_HEALTH;
+this.isClosed = false;
+
+GemFireVM[] apps = this.agent.listApplications();
+for (int i = 0; i < apps.length; i++) {
+  GemFireVM member = apps[i];
+  this.noteNewMember(member);
+}
+
+agent.addJoinLeaveListener(this);
+setDefaultGemFireHealthConfig(createGemFireHealthConfig(null));
+setDistributedSystemHealthConfig(createDistributedSystemHealthConfig());
+  }
+
+  @Override
+  public String toString() {
+StringBuffer sb = new StringBuffer();
+sb.append("closed=" + isClosed);
+sb.append("; hostMembers=" + hostMembers);
+sb.append("; okayHealth=" + 

[25/50] [abbrv] incubator-geode git commit: GEODE-288: move admin packages to internal

2016-10-27 Thread klund
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/20a32286/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/ManagedSystemMemberImpl.java
--
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/ManagedSystemMemberImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/ManagedSystemMemberImpl.java
new file mode 100644
index 000..abc6d01
--- /dev/null
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/admin/api/impl/ManagedSystemMemberImpl.java
@@ -0,0 +1,258 @@
+/*
+ * 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 org.apache.geode.internal.admin.api.AdminException;
+import org.apache.geode.internal.admin.api.ConfigurationParameter;
+import org.apache.geode.internal.admin.api.ManagedEntityConfig;
+import org.apache.geode.internal.admin.GemFireVM;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+
+/**
+ * A SystemMember 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.
+ *
+ * @since GemFire 4.0
+ */
+public abstract class ManagedSystemMemberImpl extends SystemMemberImpl
+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 //
+
+  /**
+   * Creates a new ManagedSystemMemberImpl that represents an 
existing member of an
+   * AdminDistributedSystem.
+   */
+  protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, 
GemFireVM vm)
+  throws AdminException {
+
+super(system, vm);
+this.controller = system.getEntityController();
+  }
+
+  /**
+   * Creates a new ManagedSystemMemberImpl that represents a 
non-existing member with
+   * the given ManagedEntityConfig that has not yet been started.
+   */
+  protected ManagedSystemMemberImpl(AdminDistributedSystemImpl system, 
ManagedEntityConfig config)
+  throws AdminException {
+
+super(system);
+this.internalId = null;
+this.id = getNewId();
+this.host = config.getHost();
+this.name = this.id;
+this.controller = system.getEntityController();
+  }
+
+  // Instance Methods //
+
+  public String getWorkingDirectory() {
+return this.getEntityConfig().getWorkingDirectory();
+  }
+
+  public void setWorkingDirectory(String workingDirectory) {
+this.getEntityConfig().setWorkingDirectory(workingDirectory);
+  }
+
+  public String getProductDirectory() {
+return this.getEntityConfig().getProductDirectory();
+  }
+
+  public void setProductDirectory(String productDirectory) {
+this.getEntityConfig().setProductDirectory(productDirectory);
+  }
+
+  @Override
+  public String getHost() {
+return this.getEntityConfig().getHost();
+  }
+
+  public int setState(int state) {
+if (this.stateChange == null) {
+  // The initial state is set in the constructor before
+  // stateChange is initialized.
+  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.
+   */
+  protected boolean needToStop() {
+synchronized (this.stateChange) {
+  if (this.state == STOPPED || this.state == STOPPING) {
+return false;
+
+  } else {
+