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;
}
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();
}
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);
}
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>();
}
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;
}
Aggregations