// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
// 
//    private CompatibilityUtils() {
//    }
// 
//    /**
//     * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
//     */
//    public static boolean isJGroups4() {
//       final short[] decodedVersion = Version.decode(Version.version);
//       return decodedVersion[0] == 4;
//    }
// }
// 
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
//     public boolean isAvailable();
//     public Server getServer(int port);
// }


import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;
/**
 *  Copyright 2014 Red Hat, Inc.
 *
 *  Red Hat 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.openshift.ping.common;




public abstract class OpenshiftPing extends PING {

    private String clusterName;

    private final String _systemEnvPrefix;

    @Property
    private int connectTimeout = 5000;
    private int _connectTimeout;

    @Property
    private int readTimeout = 30000;
    private int _readTimeout;

    @Property
    private int operationAttempts = 3;
    private int _operationAttempts;

    @Property
    private long operationSleep = 1000;
    private long _operationSleep;

    private static Method sendDownMethod; //handled via reflection due to JGroups 3/4 incompatibility

    public OpenshiftPing(String systemEnvPrefix) {
        super();
        _systemEnvPrefix = trimToNull(systemEnvPrefix);
        try {
// Path: common/src/main/java/org/openshift/ping/common/compatibility/CompatibilityUtils.java
// public class CompatibilityUtils {
// 
//    private CompatibilityUtils() {
//    }
// 
//    /**
//     * @return <code>true</code> when JGroups 4 is on the classpath. <code>false</code> otherwise.
//     */
//    public static boolean isJGroups4() {
//       final short[] decodedVersion = Version.decode(Version.version);
//       return decodedVersion[0] == 4;
//    }
// }
// 
// Path: common/src/main/java/org/openshift/ping/common/server/ServerFactory.java
// public interface ServerFactory {
//     public boolean isAvailable();
//     public Server getServer(int port);
// }


// Path: common/src/main/java/org/openshift/ping/common/OpenshiftPing.java
import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.openshift.ping.common.compatibility.CompatibilityException;
import org.openshift.ping.common.compatibility.CompatibilityUtils;
import org.openshift.ping.common.server.ServerFactory;
import static org.openshift.ping.common.Utils.getSystemEnvInt;
import static org.openshift.ping.common.Utils.trimToNull;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.PhysicalAddress;
import org.jgroups.annotations.Property;
import org.jgroups.protocols.PING;

/**
 *  Copyright 2014 Red Hat, Inc.
 *
 *  Red Hat 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.openshift.ping.common;




public abstract class OpenshiftPing extends PING {

    private String clusterName;

    private final String _systemEnvPrefix;

    @Property
    private int connectTimeout = 5000;
    private int _connectTimeout;

    @Property
    private int readTimeout = 30000;
    private int _readTimeout;

    @Property
    private int operationAttempts = 3;
    private int _operationAttempts;

    @Property
    private long operationSleep = 1000;
    private long _operationSleep;

    private static Method sendDownMethod; //handled via reflection due to JGroups 3/4 incompatibility

    public OpenshiftPing(String systemEnvPrefix) {
        super();
        _systemEnvPrefix = trimToNull(systemEnvPrefix);
        try {
            if(CompatibilityUtils.isJGroups4()) {