/** * publish info about a map pair (key/value) to other nodes in the cluster * @param key Object * @param value Object * @return Member - the backup node * @throws ChannelException */ protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException { if (! (key instanceof Serializable && value instanceof Serializable) ) return new Member[0]; //select a backup node Member[] backup = getMapMembers(); if (backup == null || backup.length == 0) return null; //publish the data out to all nodes MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); getChannel().send(getMapMembers(), msg, getChannelSendOptions()); return backup; }
/** * Stop this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { Map<String, Object> map = ((ReplApplContext) this.context) .getAttributeMap(); super.stopInternal(); if (map instanceof ReplicatedMap) { ((ReplicatedMap<?, ?>) map).breakdown(); } }
@Override public void mapMemberAdded(Member member) { if ( member.equals(getChannel().getLocalMember(false)) ) return; boolean memberAdded = false; synchronized (mapMembers) { if (!mapMembers.containsKey(member) ) { mapMembers.put(member, Long.valueOf(System.currentTimeMillis())); memberAdded = true; } } if ( memberAdded ) { synchronized (stateMutex) { Member[] backup = getMapMembers(); for (Entry<K, MapEntry<K, V>> e : innerMap.entrySet()) { MapEntry<K,V> entry = innerMap.get(e.getKey()); if ( entry == null ) continue; if (entry.isPrimary() && !inSet(member,entry.getBackupNodes())) { entry.setBackupNodes(backup); } } } } }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { super.startInternal(); try { CatalinaCluster catclust = (CatalinaCluster)this.getCluster(); if ( catclust != null ) { ReplicatedMap<String,Object> map = new ReplicatedMap<>( this, catclust.getChannel(),DEFAULT_REPL_TIMEOUT, getName(),getClassLoaders()); map.setChannelSendOptions(mapSendOptions); ((ReplApplContext)this.context).setAttributeMap(map); } } catch ( Exception x ) { log.error(sm.getString("replicatedContext.startUnable", getName()),x); throw new LifecycleException(sm.getString("replicatedContext.startFailed", getName()),x); } }
ReplicatedMap<String,SingleSignOnEntry> cache = new ReplicatedMap<>( this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache", cls, terminateOnStartFailure); cache.setChannelSendOptions(mapSendOptions); cache.setAccessTimeout(accessTimeout); this.cache = cache; } catch (Throwable t) {
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { try { CatalinaCluster catclust = (CatalinaCluster)this.getCluster(); if (this.context == null) this.context = new ReplApplContext(this); if ( catclust != null ) { ReplicatedMap map = new ReplicatedMap(this,catclust.getChannel(),DEFAULT_REPL_TIMEOUT, getName(),getClassLoaders()); map.setChannelSendOptions(mapSendOptions); ((ReplApplContext)this.context).setAttributeMap(map); if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName()); } super.startInternal(); } catch ( Exception x ) { log.error("Unable to start ReplicatedContext",x); throw new LifecycleException("Failed to start ReplicatedContext",x); } }
/** * publish info about a map pair (key/value) to other nodes in the cluster * @param key Object * @param value Object * @return Member - the backup node * @throws ChannelException */ @Override protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException { if (! (key instanceof Serializable && value instanceof Serializable) ) return new Member[0]; //select a backup node Member[] backup = getMapMembers(); if (backup == null || backup.length == 0) return null; //publish the data out to all nodes MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); getChannel().send(getMapMembers(), msg, getChannelSendOptions()); return backup; }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { try { CatalinaCluster catclust = (CatalinaCluster)this.getCluster(); if (this.context == null) this.context = new ReplApplContext(this); if ( catclust != null ) { ReplicatedMap<String,Object> map = new ReplicatedMap<>( this, catclust.getChannel(),DEFAULT_REPL_TIMEOUT, getName(),getClassLoaders()); map.setChannelSendOptions(mapSendOptions); ((ReplApplContext)this.context).setAttributeMap(map); if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName()); } super.startInternal(); } catch ( Exception x ) { log.error("Unable to start ReplicatedContext",x); throw new LifecycleException("Failed to start ReplicatedContext",x); } }
/** * Stop this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { super.stopInternal(); Map<String,Object> map = ((ReplApplContext)this.context).getAttributeMap(); if ( map!=null && map instanceof ReplicatedMap) { ((ReplicatedMap<?,?>)map).breakdown(); } }
/** * publish info about a map pair (key/value) to other nodes in the cluster * @param key Object * @param value Object * @return Member - the backup node * @throws ChannelException */ @Override protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException { if (! (key instanceof Serializable && value instanceof Serializable) ) return new Member[0]; //select a backup node Member[] backup = getMapMembers(); if (backup == null || backup.length == 0) return null; //publish the data out to all nodes MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); getChannel().send(getMapMembers(), msg, getChannelSendOptions()); return backup; }
/** * Stop this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { super.stopInternal(); if (getCluster() != null) { ((ReplicatedMap<?,?>) cache).breakdown(); } } }
if (! (key instanceof Serializable && value instanceof Serializable) ) return new Member[0]; Member[] backup = getMapMembers(); MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable) key, (Serializable) value, null,channel.getLocalMember(false), backup); getChannel().send(backup, msg, getChannelSendOptions()); } catch (ChannelException e) { FaultyMember[] faultyMembers = e.getFaultyMembers(); backup = excludeFromSet(realFaultyMembers, backup); if (backup.length == 0) { throw e; } else { if (getLog().isWarnEnabled()) { getLog().warn(sm.getString("replicatedMap.unableReplicate.completely", key, Arrays.toString(backup), Arrays.toString(realFaultyMembers)), e);
/** * Stop this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { super.stopInternal(); AbstractMap<String,Object> map = ((ReplApplContext)this.context).getAttributeMap(); if ( map!=null && map instanceof ReplicatedMap) { ((ReplicatedMap)map).breakdown(); } }
@Override public void memberDisappeared(Member member) { boolean removed = false; Log log = getLog(); synchronized (mapMembers) { removed = (mapMembers.remove(member) != null ); if (entry.isPrimary()) { try { Member[] backup = getMapMembers(); if (backup.length > 0) { MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_NOTIFY_MAPMEMBER,false, (Serializable)entry.getKey(),null,null,channel.getLocalMember(false),backup); getChannel().send(backup, msg, getChannelSendOptions()); entry.setProxy(false); entry.setCopy(false); Member[] backup = getMapMembers(); if (backup.length > 0) { MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_NOTIFY_MAPMEMBER,false, (Serializable)entry.getKey(),null,null,channel.getLocalMember(false),backup); getChannel().send(backup, msg, getChannelSendOptions());