public Object getFromCache(final String componentName, final String memberTokenId, final Serializable key) throws GMSException { if (key != null && componentName != null && memberTokenId != null) { GMSCacheable cKey = createCompositeKey(componentName, memberTokenId, key); cKey = getTrueKey(cKey); return cache.get(cKey); } else { //TODO: Localize throw new GMSException( new StringBuffer().append( "DistributedStateCache: ") .append("componentName, memberTokenId and key ") .append("are required parameters and cannot be null") .toString()); } }
public GroupManagementService getGMS(String groupName) { //return the gms instance for that group try { return GMSFactory.getGMSModule(groupName); } catch (GMSException e) { GMS_LOGGER.log(LogLevel.SEVERE, GMS_EXCEPTION_CANNOT_GET_GROUP_MODULE, new Object [] {groupName , e.getLocalizedMessage()}); return null; } }
void logSendMsgFailure(GMSException t, String targetMemberName, String message) { final long SEND_FAILED_NOTIFICATION_PERIOD = 1000 * 60 * 60 * 12 ; // within a 12 hour period,only notify once. if (targetMemberName == null) { targetMemberName = ""; } final Long lastNotify = lastSendMsgFailNotification.get(targetMemberName); final long currentTime = System.currentTimeMillis(); if (lastNotify == null || currentTime > lastNotify + SEND_FAILED_NOTIFICATION_PERIOD) { lastSendMsgFailNotification.put(targetMemberName, new Long(currentTime)); if (logger.isLoggable(Level.FINE)) { logger.log(Level.WARNING, message, t); } else { Throwable causeT = t.getCause(); String cause = causeT == null ? t.getMessage() : causeT.getMessage(); logger.log(Level.WARNING, message + " Cause:" + cause); } } }
public Object getFromCache(final String componentName, final String memberTokenId, final Serializable key) throws GMSException { if (key != null && componentName != null && memberTokenId != null) { GMSCacheable cKey = createCompositeKey(componentName, memberTokenId, key); cKey = getTrueKey(cKey); return cache.get(cKey); } else { //TODO: Localize throw new GMSException( new StringBuffer().append( "DistributedStateCache: ") .append("componentName, memberTokenId and key ") .append("are required parameters and cannot be null") .toString()); } }
} catch (GMSException e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "GMSException during DSC sync " + e.getLocalizedMessage(), e);
@Override public void join() throws GMSException { viewWindowThread = isWatchdog() ? null : new Thread(viewWindow, "GMS ViewWindowThread Group-" + groupName); messageWindow = new MessageWindow(groupName, messageQueue); messageWindowThread = new Thread(messageWindow, "GMS MessageWindowThread Group-" + groupName); messageWindowThread.setDaemon(true); messageWindowThread.start(); if (viewWindowThread != null) { viewWindowThread.setDaemon(true); viewWindowThread.start(); } final Map<String, String> idMap = new HashMap<String, String>(); idMap.put(CustomTagNames.MEMBER_TYPE.toString(), memberType); idMap.put(CustomTagNames.GROUP_NAME.toString(), groupName); idMap.put(CustomTagNames.START_TIME.toString(), startTime.toString()); try { groupCommunicationProvider.initializeGroupCommunicationProvider( serverToken, groupName, idMap, configProperties); groupCommunicationProvider.join(); } catch (Throwable t) { // transport can throw IllegalStateException if not able to start up correctly. GMSException ge = new GMSException("failed to join group " + groupName, t); throw ge; } }
} catch (GMSException e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "GMSException during DSC sync " + e.getLocalizedMessage(), e);
@Override public void join() throws GMSException { viewWindowThread = isWatchdog() ? null : new Thread(viewWindow, "GMS ViewWindowThread Group-" + groupName); messageWindow = new MessageWindow(groupName, messageQueue); messageWindowThread = new Thread(messageWindow, "GMS MessageWindowThread Group-" + groupName); messageWindowThread.setDaemon(true); messageWindowThread.start(); if (viewWindowThread != null) { viewWindowThread.setDaemon(true); viewWindowThread.start(); } final Map<String, String> idMap = new HashMap<String, String>(); idMap.put(CustomTagNames.MEMBER_TYPE.toString(), memberType); idMap.put(CustomTagNames.GROUP_NAME.toString(), groupName); idMap.put(CustomTagNames.START_TIME.toString(), startTime.toString()); try { groupCommunicationProvider.initializeGroupCommunicationProvider( serverToken, groupName, idMap, configProperties); groupCommunicationProvider.join(); } catch (Throwable t) { // transport can throw IllegalStateException if not able to start up correctly. GMSException ge = new GMSException("failed to join group " + groupName, t); throw ge; } }
private void forceDSCSync(final DistributedStateCacheImpl dsc) { if (isWatchdog()) { return; } try { final String token = getGMSContext().getGroupCommunicationProvider() .getGroupLeader(); if (logger.isLoggable(Level.FINE)){ logger.log(Level.FINE, "Force Syncing DistributedStateCache with " + token); } dsc.syncCache(token, true); } catch (GMSException e) { logger.log(Level.WARNING,"gh.dsc.force.sync.failed", new Object[]{e.getLocalizedMessage()}); } }
public void announceWatchdogObservedFailure(String serverToken) throws GMSException { if (!isWatchdog()) { throw new GMSException("illegal state: announceWatchdogObservedFailure operation is only valid for a WATCHDOG member."); } GroupHandle gh = ctx.getGroupHandle(); ctx.getGroupCommunicationProvider().announceWatchdogObservedFailure(serverToken); }
private void forceDSCSync(final DistributedStateCacheImpl dsc) { if (isWatchdog()) { return; } try { final String token = getGMSContext().getGroupCommunicationProvider() .getGroupLeader(); if (logger.isLoggable(Level.FINE)){ logger.log(Level.FINE, "Force Syncing DistributedStateCache with " + token); } dsc.syncCache(token, true); } catch (GMSException e) { logger.log(Level.WARNING,"gh.dsc.force.sync.failed", new Object[]{e.getLocalizedMessage()}); } }
public void announceWatchdogObservedFailure(String serverToken) throws GMSException { if (!isWatchdog()) { throw new GMSException("illegal state: announceWatchdogObservedFailure operation is only valid for a WATCHDOG member."); } GroupHandle gh = ctx.getGroupHandle(); ctx.getGroupCommunicationProvider().announceWatchdogObservedFailure(serverToken); }
} catch (GMSException e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "GMSException during DSC sync " + e.getLocalizedMessage(), e);
/** * This returns an instance of the GroupManagementService for a given * non-null group name. * @param groupName groupName * @return GroupManagementService * @throws GMSException - if the groupName is null * * @throws GMSNotEnabledException - If GMS is not enabled * @throws GMSNotInitializedException - If GMS is not initialized */ public static GroupManagementService getGMSModule(final String groupName) throws GMSNotEnabledException, GMSException, GMSNotInitializedException { if(groupName == null){ throw new GMSException(sm.get("ex.factory.start.missing.group")); } final String key = getCompositeKey(groupName); if(groups.containsKey(key)) return groups.get(key); else if(!isGMSEnabled(groupName)){ throw new GMSNotEnabledException(sm.get("ex.factory.get.gms.is.disabled", new Object[]{groupName})); } else { throw new GMSNotInitializedException(sm.get("ex.factory.get.not.init", new Object[]{groupName})); } } /**
} catch (GMSException e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "GMSException during DSC sync " + e.getLocalizedMessage(), e);
/** * This returns an instance of the GroupManagementService for a given * non-null group name. * @param groupName groupName * @return GroupManagementService * @throws GMSException - if the groupName is null * * @throws GMSNotEnabledException - If GMS is not enabled * @throws GMSNotInitializedException - If GMS is not initialized */ public static GroupManagementService getGMSModule(final String groupName) throws GMSNotEnabledException, GMSException, GMSNotInitializedException { if(groupName == null){ throw new GMSException(sm.get("ex.factory.start.missing.group")); } final String key = getCompositeKey(groupName); if(groups.containsKey(key)) return groups.get(key); else if(!isGMSEnabled(groupName)){ throw new GMSNotEnabledException(sm.get("ex.factory.get.gms.is.disabled", new Object[]{groupName})); } else { throw new GMSNotInitializedException(sm.get("ex.factory.get.not.init", new Object[]{groupName})); } } /**
getGMSContext().getGroupName()); } catch (GMSException e) { logger.log(Level.INFO, e.getLocalizedMessage(), e);
public void sendMessage(List<String> targetServerTokens, String targetComponentName, byte[] message) throws GMSException { Throwable lastThrowable = null; String failedSendToken = null; final GMSMessage gMsg = new GMSMessage(targetComponentName, message, groupName, getGMSContext().getStartTime()); if(targetServerTokens.isEmpty()){ getGMSContext().getGroupCommunicationProvider().sendMessage(null,gMsg, true ); } else { for(String token : targetServerTokens){ try { getGMSContext().getGroupCommunicationProvider().sendMessage(token, gMsg, false ); } catch (Throwable t) { lastThrowable = t; failedSendToken = token; logger.log(Level.WARNING, "group.handle.sendmessage.failed", new Object[]{message,targetComponentName,token, t.getLocalizedMessage()}); } } } if (lastThrowable != null) { if (lastThrowable instanceof GMSException) { throw (GMSException) lastThrowable; } else { throw new GMSException("failed to send message to target server:" + failedSendToken + " target component=" + targetComponentName, lastThrowable); } } }
getGMSContext().getGroupName()); } catch (GMSException e) { logger.log(Level.INFO, e.getLocalizedMessage(), e);
public void sendMessage(List<String> targetServerTokens, String targetComponentName, byte[] message) throws GMSException { Throwable lastThrowable = null; String failedSendToken = null; final GMSMessage gMsg = new GMSMessage(targetComponentName, message, groupName, getGMSContext().getStartTime()); if(targetServerTokens.isEmpty()){ getGMSContext().getGroupCommunicationProvider().sendMessage(null,gMsg, true ); } else { for(String token : targetServerTokens){ try { getGMSContext().getGroupCommunicationProvider().sendMessage(token, gMsg, false ); } catch (Throwable t) { lastThrowable = t; failedSendToken = token; logger.log(Level.WARNING, "group.handle.sendmessage.failed", new Object[]{message,targetComponentName,token, t.getLocalizedMessage()}); } } } if (lastThrowable != null) { if (lastThrowable instanceof GMSException) { throw (GMSException) lastThrowable; } else { throw new GMSException("failed to send message to target server:" + failedSendToken + " target component=" + targetComponentName, lastThrowable); } } }