AbstractReplicatedMap
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.apache.catalina.tribes.tipis.AbstractReplicatedMap (Showing top 20 results out of 315)

origin: codefollower/Tomcat-Research

@Override
public void clear() {
  clear(true);
}
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public Object remove(Object key, boolean notify) {
  MapEntry entry = (MapEntry)super.remove(key);
  try {
    if (getMapMembers().length > 0 && notify) {
      MapMessage msg = new MapMessage(getMapContextName(), MapMessage.MSG_REMOVE, false, (Serializable) key, null, null, null,null);
      getChannel().send(getMapMembers(), msg, getChannelSendOptions());
    }
  } catch ( ChannelException x ) {
    log.error("Unable to replicate out data for a LazyReplicatedMap.remove operation",x);
  }
  return entry!=null?entry.getValue():null;
}

origin: org.apache.tomcat/tomcat-tribes

public Member getNextBackupNode() {
  Member[] members = getMapMembers();
  int node = getNextBackupIndex();
  if ( members.length == 0 || node==-1) return null;
  if ( node >= members.length ) node = 0;
  return members[node];
}
origin: org.apache.tomcat/tomcat-tribes

  backup = publishEntryInfo(key, entry.getValue());
} else if ( entry.isProxy() ) {
  msg = new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP, false,
             (Serializable) key, null, null, null,null);
  Response[] resp = getRpcChannel().send(entry.getBackupNodes(),msg, RpcChannel.FIRST_REPLY, getChannelSendOptions(), getRpcTimeout());
  if (resp == null || resp.length == 0 || resp[0].getMessage() == null) {
  msg.deserialize(getExternalLoaders());
  backup = entry.getBackupNodes();
  if ( msg.getValue()!=null ) entry.setValue((V) msg.getValue());
  msg = new MapMessage(getMapContextName(), MapMessage.MSG_NOTIFY_MAPMEMBER,false,
      (Serializable)entry.getKey(), null, null, channel.getLocalMember(false), backup);
  if ( backup != null && backup.length > 0) {
    getChannel().send(backup, msg, getChannelSendOptions());
  msg = new MapMessage(getMapContextName(),MapMessage.MSG_PROXY,false,(Serializable)key,null,null,channel.getLocalMember(false),backup);
  Member[] dest = getMapMembersExcl(backup);
  if ( dest!=null && dest.length >0) {
    getChannel().send(dest, msg, getChannelSendOptions());
    val.setOwner(getMapOwner());
  backup = getMapMembers();
  if (backup.length > 0) {
    msg = new MapMessage(getMapContextName(), MapMessage.MSG_NOTIFY_MAPMEMBER,false,
        (Serializable)key,null,null,channel.getLocalMember(false),backup);
    getChannel().send(backup, msg, getChannelSendOptions());
origin: codefollower/Tomcat-Research

public void transferState() {
  try {
    Member[] members = getMapMembers();
    Member backup = members.length > 0 ? (Member) members[0] : null;
    if (backup != null) {
      MapMessage msg = new MapMessage(mapContextName, getStateMessageType(), false,
                      null, null, null, null, null);
      Response[] resp = rpcChannel.send(new Member[] {backup}, msg, RpcChannel.FIRST_REPLY, channelSendOptions, rpcTimeout);
      if (resp.length > 0) {
        synchronized (stateMutex) {
          msg = (MapMessage) resp[0].getMessage();
          msg.deserialize(getExternalLoaders());
          ArrayList<?> list = (ArrayList<?>) msg.getValue();
          for (int i = 0; i < list.size(); i++) {
            messageReceived( (Serializable) list.get(i), resp[0].getSource());
          } //for
        }
      } else {
        log.warn("Transfer state, 0 replies, probably a timeout.");
      }
    }
  } catch (ChannelException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  } catch (IOException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  } catch (ClassNotFoundException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  }
  stateTransferred = true;
}
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

  mapmsg.deserialize(getExternalLoaders());
} catch (IOException x) {
  log.error("Unable to deserialize MapMessage.", x);
  log.trace("Map message received from:"+sender.getName()+" msg:"+mapmsg);
if (mapmsg.getMsgType() == MapMessage.MSG_START) {
  mapMemberAdded(mapmsg.getPrimary());
  memberDisappeared(mapmsg.getPrimary());
    entry.setPrimary(mapmsg.getPrimary());
    if (mapmsg.getValue()!=null && mapmsg.getValue() instanceof ReplicatedMapEntry ) {
      ((ReplicatedMapEntry)mapmsg.getValue()).setOwner(getMapOwner());
        ((ReplicatedMapEntry)entry.getValue()).setOwner(getMapOwner());
      re.setOwner(getMapOwner());
      entry.setValue(re);
    } else {
origin: codefollower/Tomcat-Research

public V put(K key, V value, boolean notify) {
  MapEntry<K,V> entry = new MapEntry<>(key, value);
  entry.setBackup(false);
  entry.setProxy(false);
  entry.setPrimary(channel.getLocalMember(false));
  V old = null;
  //make sure that any old values get removed
  if ( containsKey(key) ) old = remove(key);
  try {
    if ( notify ) {
      Member[] backup = publishEntryInfo(key, value);
      entry.setBackupNodes(backup);
    }
  } catch (ChannelException x) {
    log.error("Unable to replicate out data for a LazyReplicatedMap.put operation", x);
  }
  innerMap.put(key,entry);
  return old;
}
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

/**
 * If the reply has already been sent to the requesting thread,
 * the rpc callback can handle any data that comes in after the fact.
 * @param msg Serializable
 * @param sender Member
 */
public void leftOver(Serializable msg, Member sender) {
  //left over membership messages
  if (! (msg instanceof MapMessage))return;
  MapMessage mapmsg = (MapMessage) msg;
  try {
    mapmsg.deserialize(getExternalLoaders());
    if (mapmsg.getMsgType() == MapMessage.MSG_START) {
      mapMemberAdded(mapmsg.getPrimary());
    } else if (mapmsg.getMsgType() == MapMessage.MSG_INIT) {
      memberAlive(mapmsg.getPrimary());
    }
  } catch (IOException x ) {
    log.error("Unable to deserialize MapMessage.",x);
  } catch (ClassNotFoundException x ) {
    log.error("Unable to deserialize MapMessage.",x);
  }
}
origin: org.apache.tomcat/tomcat-tribes

  MapMessage mapMsg = (MapMessage)resp[i].getMessage();
  try {
    mapMsg.deserialize(getExternalLoaders());
    Member member = resp[i].getSource();
    State state = (State) mapMsg.getValue();
    if (state.isAvailable()) {
      memberAlive(member);
    } else if (state == State.STATETRANSFERRED) {
      synchronized (mapMembers) {
  memberDisappeared(faultyMember.getMember());
if ( (now - access) > timeout ) {
  log.warn(sm.getString("abstractReplicatedMap.ping.timeout", member, mapname));
  memberDisappeared(member);
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public void mapMemberAdded(Member member) {
  if ( member.equals(getChannel().getLocalMember(false)) ) return;
  boolean memberAdded = false;
        if (entry.isPrimary() && (entry.getBackupNodes() == null || entry.getBackupNodes().length == 0)) {
          try {
            Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue());
            entry.setBackupNodes(backup);
            entry.setPrimary(channel.getLocalMember(false));
origin: codefollower/Tomcat-Research

  broadcast(MapMessage.MSG_INIT, true);
  transferState();
  broadcast(MapMessage.MSG_START, true);
} catch (ChannelException x) {
  log.warn("Unable to send map start message.");
  if (terminate) {
    breakdown();
    throw new RuntimeException("Unable to start replicated map.",x);
origin: codefollower/Tomcat-Research

public Member[] getMapMembers() {
  return getMapMembers(this.mapMembers);
}
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

  broadcast(MapMessage.MSG_INIT, true);
  transferState();
  broadcast(MapMessage.MSG_START, true);
} catch (ChannelException x) {
  log.warn("Unable to send map start message.");
origin: org.apache.tomcat/tomcat-tribes

public void breakdown() {
  this.state = State.DESTROYED;
  if (this.rpcChannel != null) {
    this.rpcChannel.breakdown();
  }
  if (this.channel != null) {
    try {broadcast(MapMessage.MSG_STOP,false); }catch ( Exception ignore){}
    //cleanup
    this.channel.removeChannelListener(this);
    this.channel.removeMembershipListener(this);
  }
  this.rpcChannel = null;
  this.channel = null;
  this.mapMembers.clear();
  innerMap.clear();
  this.stateTransferred = false;
  this.externalLoaders = null;
}
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

if ( !entry.isBackup() ) {
  msg = new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP, false,
             (Serializable) key, null, null, null,null);
  Response[] resp = getRpcChannel().send(entry.getBackupNodes(),msg, this.getRpcChannel().FIRST_REPLY, Channel.SEND_OPTIONS_DEFAULT, getRpcTimeout());
  if (resp == null || resp.length == 0) {
  msg.deserialize(getExternalLoaders());
  backup = entry.getBackupNodes();
  if ( entry.getValue() instanceof ReplicatedMapEntry ) {
    ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
    val.setOwner(getMapOwner());
  backup = publishEntryInfo(key, entry.getValue());
} else if ( entry.isProxy() ) {
  msg = new MapMessage(getMapContextName(),MapMessage.MSG_PROXY,false,(Serializable)key,null,null,channel.getLocalMember(false),backup);
  Member[] dest = getMapMembersExcl(backup);
  if ( dest!=null && dest.length >0) {
    getChannel().send(dest, msg, getChannelSendOptions());
    val.setOwner(getMapOwner());   
entry.setBackup(false);
entry.setProxy(false);
if ( getMapOwner()!=null ) getMapOwner().objectMadePrimay(key, entry.getValue());
origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public void transferState() {
  try {
    Member[] members = getMapMembers();
    Member backup = members.length > 0 ? (Member) members[0] : null;
    if (backup != null) {
      MapMessage msg = new MapMessage(mapContextName, getStateMessageType(), false,
                      null, null, null, null, null);
      Response[] resp = rpcChannel.send(new Member[] {backup}, msg, rpcChannel.FIRST_REPLY, channelSendOptions, rpcTimeout);
      if (resp.length > 0) {
        synchronized (stateMutex) {
          msg = (MapMessage) resp[0].getMessage();
          msg.deserialize(getExternalLoaders());
          ArrayList list = (ArrayList) msg.getValue();
          for (int i = 0; i < list.size(); i++) {
            messageReceived( (Serializable) list.get(i), resp[0].getSource());
          } //for
        }
      } else {
        log.warn("Transfer state, 0 replies, probably a timeout.");
      }
    }
  } catch (ChannelException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  } catch (IOException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  } catch (ClassNotFoundException x) {
    log.error("Unable to transfer LazyReplicatedMap state.", x);
  }
  stateTransferred = true;
}
origin: codefollower/Tomcat-Research

  mapmsg.deserialize(getExternalLoaders());
} catch (IOException x) {
  log.error("Unable to deserialize MapMessage.", x);
  log.trace("Map message received from:"+sender.getName()+" msg:"+mapmsg);
if (mapmsg.getMsgType() == MapMessage.MSG_START) {
  mapMemberAdded(mapmsg.getPrimary());
  memberDisappeared(mapmsg.getPrimary());
    entry.setPrimary(mapmsg.getPrimary());
    if (mapmsg.getValue()!=null && mapmsg.getValue() instanceof ReplicatedMapEntry ) {
      ((ReplicatedMapEntry)mapmsg.getValue()).setOwner(getMapOwner());
        ((ReplicatedMapEntry)entry.getValue()).setOwner(getMapOwner());
      re.setOwner(getMapOwner());
      entry.setValue((V) re);
    } else {
origin: org.apache.geronimo.ext.tomcat/tribes

public Object put(Object key, Object value, boolean notify) {
  MapEntry entry = new MapEntry(key,value);
  entry.setBackup(false);
  entry.setProxy(false);
  entry.setPrimary(channel.getLocalMember(false));
  Object old = null;
  //make sure that any old values get removed
  if ( containsKey(key) ) old = remove(key);
  try {
    if ( notify ) {
      Member[] backup = publishEntryInfo(key, value);
      entry.setBackupNodes(backup);
    }
  } catch (ChannelException x) {
    log.error("Unable to replicate out data for a LazyReplicatedMap.put operation", x);
  }
  super.put(key,entry);
  return old;
}
origin: org.apache.geronimo.ext.tomcat/tribes

/**
 * If the reply has already been sent to the requesting thread,
 * the rpc callback can handle any data that comes in after the fact.
 * @param msg Serializable
 * @param sender Member
 */
@Override
public void leftOver(Serializable msg, Member sender) {
  //left over membership messages
  if (! (msg instanceof MapMessage))return;
  MapMessage mapmsg = (MapMessage) msg;
  try {
    mapmsg.deserialize(getExternalLoaders());
    if (mapmsg.getMsgType() == MapMessage.MSG_START) {
      mapMemberAdded(mapmsg.getPrimary());
    } else if (mapmsg.getMsgType() == MapMessage.MSG_INIT) {
      memberAlive(mapmsg.getPrimary());
    }
  } catch (IOException x ) {
    log.error("Unable to deserialize MapMessage.",x);
  } catch (ClassNotFoundException x ) {
    log.error("Unable to deserialize MapMessage.",x);
  }
}
origin: org.apache.geronimo.ext.tomcat/tribes

public Member getNextBackupNode() {
  Member[] members = getMapMembers();
  int node = getNextBackupIndex();
  if ( members.length == 0 || node==-1) return null;
  if ( node >= members.length ) node = 0;
  return members[node];
}
org.apache.catalina.tribes.tipisAbstractReplicatedMap

Most used methods

  • broadcast
    Helper method to broadcast a message to all members in a channel
  • clear
  • containsKey
    Returns true if the key has an entry in the map. The entry can be a proxy or a backup entry, invokin
  • getChannel
  • getChannelSendOptions
  • getExternalLoaders
  • getMapContextName
  • getMapMembers
  • getMapMembersExcl
  • getMapOwner
  • getNextBackupIndex
  • getRpcChannel
  • getNextBackupIndex,
  • getRpcChannel,
  • getRpcTimeout,
  • getStateMessageType,
  • inSet,
  • init,
  • keySet,
  • mapMemberAdded,
  • memberAlive,
  • memberDisappeared

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSystemService (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JButton (javax.swing)
  • JFileChooser (javax.swing)

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)