Search in sources :

Example 1 with ClusterInstanceInfo

use of com.sun.corba.ee.spi.folb.ClusterInstanceInfo in project Payara by payara.

the class IiopFolbGmsClient method getClusterInstanceInfo.

// For addMember.
private ClusterInstanceInfo getClusterInstanceInfo(String instanceName) {
    fineLog("getClusterInstanceInfo: instanceName {0}", instanceName);
    final Servers servers = services.getService(Servers.class);
    fineLog("getClusterInstanceInfo: servers {0}", servers);
    final Server server = servers.getServer(instanceName);
    fineLog("getClusterInstanceInfo: server {0}", server);
    final Config config = getConfigForServer(server);
    fineLog("getClusterInstanceInfo: servers {0}", servers);
    // assumeInstanceIsRunning is set to true since this is
    // coming from addMember, because shoal just told us that the instance is up.
    ClusterInstanceInfo result = getClusterInstanceInfo(server, config, true);
    fineLog("getClusterInstanceInfo: result {0}", result);
    return result;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) Servers(com.sun.enterprise.config.serverbeans.Servers) ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo)

Example 2 with ClusterInstanceInfo

use of com.sun.corba.ee.spi.folb.ClusterInstanceInfo in project Payara by payara.

the class IiopFolbGmsClient method getIIOPEndpoints.

// return host:port,... string for all clear text ports in the cluster
// instance info.
public final String getIIOPEndpoints() {
    final Map<String, ClusterInstanceInfo> cinfos = getAllClusterInstanceInfo();
    final StringBuilder result = new StringBuilder();
    boolean first = true;
    for (ClusterInstanceInfo cinfo : cinfos.values()) {
        for (SocketInfo sinfo : cinfo.endpoints()) {
            if (!sinfo.type().startsWith("SSL")) {
                if (first) {
                    first = false;
                } else {
                    result.append(',');
                }
                result.append(sinfo.host()).append(':').append(sinfo.port());
            }
        }
    }
    return result.toString();
}
Also used : SocketInfo(com.sun.corba.ee.spi.folb.SocketInfo) ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo)

Example 3 with ClusterInstanceInfo

use of com.sun.corba.ee.spi.folb.ClusterInstanceInfo in project Payara by payara.

the class RoundRobinPolicy method makeClusterInstanceInfo.

/**
 * during bootstrapping, weight is assumed "10" for all endpoints
 * then on, whenever server sends updates list,
 * create the list again here with right weights
 */
private ClusterInstanceInfo makeClusterInstanceInfo(String str, int weight) {
    // support IPV6 literal address
    String[] host_port = new String[2];
    int i = str.lastIndexOf(':');
    host_port[0] = str.substring(0, i);
    host_port[1] = str.substring(i + 1);
    // for bootstrapping, can be ""
    String server_identifier = "";
    // will be clear_text for bootstrapping
    String type = CLEAR_TEXT;
    SocketInfo socketInfo = new SocketInfo(type, host_port[0], Integer.parseInt(host_port[1]));
    List<SocketInfo> sil = new ArrayList<SocketInfo>(1);
    sil.add(socketInfo);
    return new ClusterInstanceInfo(server_identifier, weight, sil);
}
Also used : SocketInfo(com.sun.corba.ee.spi.folb.SocketInfo) ArrayList(java.util.ArrayList) ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo)

Example 4 with ClusterInstanceInfo

use of com.sun.corba.ee.spi.folb.ClusterInstanceInfo in project Payara by payara.

the class RoundRobinPolicy method getNextRotation.

/*
     * get a new shape of the endpoints
     * For e.g. if list contains A,B,C
     * if the logic below chooses B as the endpoint to send the req to
     * then return B,C,A.
     * logic used is as described in Class description comments
     */
public synchronized List<String> getNextRotation() {
    // lowerLimit
    int lowerLimit = 0;
    int random = 0;
    // totalWeight);
    while (random == 0) {
        random = rand.nextInt(totalWeight);
        if (random != 0) {
            break;
        }
    }
    // fineLog( "getNextRotation : random # = {0} sum of all weights = {1}",
    // new Object[]{random, totalWeight});
    int i = 0;
    for (ClusterInstanceInfo endpoint : endpointsList) {
        int upperLimit = lowerLimit + endpoint.weight();
        // fineLog( "upperLimit = {0}", upperLimit);
        if (random > lowerLimit && random <= upperLimit) {
            List<ClusterInstanceInfo> instanceInfo = new LinkedList<ClusterInstanceInfo>();
            // add the sublist at index 0
            instanceInfo.addAll(0, endpointsList.subList(i, endpointsList.size()));
            // add the remaining list
            instanceInfo.addAll(endpointsList.subList(0, i));
            endpointsList = instanceInfo;
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "getNextRotation: result={0}", instanceInfo);
            }
            return convertIntoCorbaloc(instanceInfo);
        }
        lowerLimit = upperLimit;
        // fineLog( "lowerLimit = {0}", lowerLimit);
        i++;
    }
    logger.log(Level.WARNING, COULD_NOT_FIND_ENDPOINT);
    return new ArrayList<String>();
}
Also used : ArrayList(java.util.ArrayList) ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo) LinkedList(java.util.LinkedList)

Example 5 with ClusterInstanceInfo

use of com.sun.corba.ee.spi.folb.ClusterInstanceInfo in project Payara by payara.

the class RoundRobinPolicy method fromHostPortStrings.

private List<ClusterInstanceInfo> fromHostPortStrings(List<String> list) {
    List<ClusterInstanceInfo> result = new LinkedList<ClusterInstanceInfo>();
    for (String elem : list) {
        ClusterInstanceInfo info = makeClusterInstanceInfo(elem, default_weight);
        result.add(info);
    }
    return result;
}
Also used : ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo) LinkedList(java.util.LinkedList)

Aggregations

ClusterInstanceInfo (com.sun.corba.ee.spi.folb.ClusterInstanceInfo)13 ArrayList (java.util.ArrayList)6 SocketInfo (com.sun.corba.ee.spi.folb.SocketInfo)5 Config (com.sun.enterprise.config.serverbeans.Config)2 Server (com.sun.enterprise.config.serverbeans.Server)2 LinkedList (java.util.LinkedList)2 GroupInfoService (com.sun.corba.ee.spi.folb.GroupInfoService)1 SocketInfo (com.sun.corba.ee.spi.transport.SocketInfo)1 Cluster (com.sun.enterprise.config.serverbeans.Cluster)1 Node (com.sun.enterprise.config.serverbeans.Node)1 Servers (com.sun.enterprise.config.serverbeans.Servers)1 PayaraCluster (fish.payara.nucleus.cluster.PayaraCluster)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 IIOPSSLUtil (org.glassfish.enterprise.iiop.api.IIOPSSLUtil)1 IiopListener (org.glassfish.orb.admin.config.IiopListener)1 IiopService (org.glassfish.orb.admin.config.IiopService)1 InvalidName (org.omg.CORBA.ORBPackage.InvalidName)1 TaggedComponent (org.omg.IOP.TaggedComponent)1