use of com.sun.enterprise.ee.cms.core.GMSException in project Payara by payara.
the class GMSAdapterImpl method initializeGMS.
private void initializeGMS() throws GMSException {
Properties configProps = new Properties();
// Default to 4 MB limit in glassfish.
int HA_MAX_GMS_MESSAGE_LENGTH = 4 * (1024 * 1024) + (2 * 1024);
configProps.put(ServiceProviderConfigurationKeys.MAX_MESSAGE_LENGTH.toString(), Integer.toString(HA_MAX_GMS_MESSAGE_LENGTH));
// read GMS configuration from domain.xml
readGMSConfigProps(configProps);
printProps(configProps);
String memberType = (String) configProps.get(MEMBERTYPE_STRING);
gms = (GroupManagementService) GMSFactory.startGMSModule(instanceName, clusterName, GroupManagementService.MemberType.valueOf(memberType), configProps);
// remove GMSLogDomain.getLogger(GMSLogDomain.GMS_LOGGER).setLevel(gmsLogLevel);
GMSFactory.setGMSEnabledState(clusterName, Boolean.TRUE);
if (gms != null) {
try {
registerJoinedAndReadyNotificationListener(this);
registerJoinNotificationListener(this);
registerFailureNotificationListener(this);
registerPlannedShutdownListener(this);
registerFailureSuspectedListener(this);
// fix gf it 12905
if (testFailureRecoveryHandler && !env.isDas()) {
// this must be here or appointed recovery server notification is not printed out for automated testing.
registerFailureRecoveryListener("GlassfishFailureRecoveryHandlerTest", this);
}
glassfishEventListener = new org.glassfish.api.event.EventListener() {
public void event(Event event) {
if (gms == null) {
// handle cases where gms is not set and for some reason this handler did not get unregistered.
return;
}
if (event.is(EventTypes.SERVER_SHUTDOWN)) {
GMS_LOGGER.log(LogLevel.INFO, GMS_SERVER_SHUTDOWN_RECEIVED, new Object[] { gms.getInstanceName(), gms.getGroupName(), event.name() });
// todo: remove these when removing the test register ones above.
removeJoinedAndReadyNotificationListener(GMSAdapterImpl.this);
removeJoinNotificationListener(GMSAdapterImpl.this);
removeFailureNotificationListener(GMSAdapterImpl.this);
removeFailureSuspectedListener(GMSAdapterImpl.this);
gms.shutdown(GMSConstants.shutdownType.INSTANCE_SHUTDOWN);
removePlannedShutdownListener(GMSAdapterImpl.this);
events.unregister(glassfishEventListener);
} else if (event.is(EventTypes.SERVER_READY)) {
// consider putting following, includding call to joinedAndReady into a timertask.
// this time would give instance time to get its heartbeat cache updated by all running
// READY cluster memebrs
// final long MAX_WAIT_DURATION = 4000;
//
// long elapsedDuration = (joinTime == 0L) ? 0 : System.currentTimeMillis() - joinTime;
// long waittime = MAX_WAIT_DURATION - elapsedDuration;
// if (waittime > 0L && waittime <= MAX_WAIT_DURATION) {
// try {
// GMS_LOGGER.info("wait " + waittime + " ms before signaling joined and ready");
// Thread.sleep(waittime);
// } catch(Throwable t) {}
// }
// validateCoreMembers();
gms.reportJoinedAndReadyState();
}
}
};
events.register(glassfishEventListener);
gms.join();
// joinTime = System.currentTimeMillis();
GMS_LOGGER.log(LogLevel.INFO, GMS_JOINED, new Object[] { instanceName, clusterName });
} catch (GMSException e) {
// failed to start so unregister event listener that calls GMS.
events.unregister(glassfishEventListener);
throw e;
}
GMS_LOGGER.log(LogLevel.INFO, GMS_STARTED, new Object[] { instanceName, clusterName });
} else
throw new GMSException("gms object is null.");
}
use of com.sun.enterprise.ee.cms.core.GMSException in project Payara by payara.
the class GMSAdapterImpl method initialize.
@Override
public boolean initialize(String clusterName) {
if (initialized.compareAndSet(false, true)) {
this.clusterName = clusterName;
if (clusterName == null) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_NO_CLUSTER_NAME);
return false;
}
try {
gms = GMSFactory.getGMSModule(clusterName);
} catch (GMSException ge) {
// ignore
}
if (gms != null) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_MULTIPLE_ADAPTER, clusterName);
return false;
}
Domain domain = habitat.getService(Domain.class);
instanceName = env.getInstanceName();
isDas = env.isDas();
cluster = server.getCluster();
if (cluster == null && clusters != null) {
// iterate over all clusters to find the cluster that has name passed in.
for (Cluster clusterI : clusters.getCluster()) {
if (clusterName.compareTo(clusterI.getName()) == 0) {
cluster = clusterI;
break;
}
}
}
if (cluster == null) {
GMS_LOGGER.log(LogLevel.WARNING, GMS_NO_CLUSTER_WARNING);
// don't enable GMS
return false;
} else if (isDas) {
// only want to do this in the case of the DAS
initializeHealthHistory(cluster);
}
clusterConfig = domain.getConfigNamed(clusterName + "-config");
if (GMS_LOGGER.isLoggable(LogLevel.CONFIG)) {
GMS_LOGGER.log(LogLevel.CONFIG, "clusterName=" + clusterName + " clusterConfig=" + clusterConfig);
}
try {
initializeGMS();
} catch (GMSException e) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_FAILED_TO_START, e);
// prevent access to a malformed gms object.
return false;
// also ensure for any unchecked exceptions (such as NPE during initialization) during initialization
// that the malformed gms object is not allowed to be accesssed through the gms adapter.
} catch (Throwable t) {
GMS_LOGGER.log(LogLevel.SEVERE, GMS_FAILED_TO_START_UNEXCEPTED, t);
// prevent access to a malformed gms object.
return false;
}
initializationComplete.set(true);
}
return initialized.get();
}
Aggregations