Exemplo n.º 1
0
 @Override
 public boolean isSucceededBy(VectorTimeStamp other) {
   Tracer.info(this, "checking if this " + this + " is succeded by  " + other);
   Set<String> keys = contents.keySet();
   boolean foundOneSuccessor = false;
   for (String key : keys) {
     int myValue = get(key);
     int otherValue = other.get(key);
     int diff = otherValue - myValue;
     if (diff == 0) {
       Tracer.info(this, "Have received same number of messages from " + key);
       continue;
     } else if (diff != 1) {
       Tracer.info(this, "Have not received " + diff + " messages from " + key);
       return false;
     } else if (foundOneSuccessor) {
       Tracer.info(this, "Have not received 1 message from a second user " + key);
       return false;
     } else {
       Tracer.info(this, "Have not received 1 message from  " + key);
       foundOneSuccessor = true;
     }
   }
   return foundOneSuccessor;
 }
Exemplo n.º 2
0
 public boolean isConcurrent(VectorTimeStamp other) {
   //		if (other.size() != size()) {
   //			throw new RuntimeException("Incomparable vector time stamps: this:" + this + " other:" +
   // other );
   //		}
   Tracer.info(this, "Checking if this " + this + " is concurrent with " + other);
   Set<String> keys = contents.keySet();
   //		Set<String> otherKeys = other.users();
   //		keys.addAll(otherKeys);
   boolean otherGreater = false;
   boolean thisGreater = false;
   for (String key : keys) {
     int myValue = get(key);
     int otherValue = other.get(key);
     int diff = myValue - otherValue;
     if (diff == 0) {
       continue;
     } else if (diff > 0) {
       thisGreater = true;
       Tracer.info(this, "This has received " + diff + " additional messages from " + key);
       if (otherGreater) {
         Tracer.info(this, "The two time stamps are concurrent");
         return true;
       }
     } else {
       otherGreater = true;
       Tracer.info(this, "This has received " + -diff + " fewer messages from " + key);
       if (thisGreater) {
         Tracer.info(this, "The two time stamps are concurrent");
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public void send(Set<String> clientNames, Object message) {
   if (clientNames.size() == 0) return;
   //		ByteBuffer message = bufferSerializationSupport.outputBufferFromSerializable(object);
   //		bbGroupServerInputPort.send(clientNames, message);
   //		if (message instanceof  ByteBuffer) {
   ////			bbGroupServerInputPort.send(clientNames, (ByteBuffer) message);
   //			Message.info(this, "Cannot send byte buffer on object port");
   //			return;
   //		}
   if (!(message instanceof Serializable)) {
     Tracer.info(this, "Can only send seralizable on object group port");
     return;
   }
   Tracer.info(this, "Sending group message:" + message + " to:" + clientNames);
   //		unOptimizedObjectForwarder.send(remoteName, message);
   //		if (bbGroupServerInputPort != null)
   //			sendOptimized(clientNames, message);
   //		else
   //			sendUnoptimized(clientNames, message);
   groupSendTrapper.send(clientNames, message);
   //		if (bbGroupServerInputPort != null)
   //			optimizedObjectForwarder.send(clientNames, message);
   //		else {
   //			for (String clientName:clientNames) {
   //				unOptimizedObjectForwarder.send(clientName, message);
   //			}
   //		}
 }
Exemplo n.º 4
0
  @Override
  public synchronized void join(
      String theClientName, ObjectReceiver theClient, String theApplicationName) {
    try {
      Tracer.info(this, "Entering Session Join");
      SessionJoinInformationUpdated.newCase(
          CommunicatorSelector.getProcessName(), theClientName, theApplicationName, myName, this);
      JoinInfo retVal = new JoinInfo();
      retVal.newSession = clients.size() == 0;
      ProcessGroup processGroupRemote = multicastGroups.get(theApplicationName);
      ProcessGroupLocal procesGroupLocal = localProcessGroups.get(theApplicationName);
      retVal.newApplication = processGroupRemote == null;

      if (processGroupRemote == null) {
        MulticastGroupCreated.newCase(CommunicatorSelector.getProcessName(), myName, this);
        AProcessGroup processGroup = new AProcessGroup(myName, theApplicationName, null);
        procesGroupLocal = processGroup;
        addSessionListenerLocal(procesGroupLocal);
        processGroupRemote = (ProcessGroup) UnicastRemoteObject.exportObject(processGroup, 0);
        multicastGroups.put(theApplicationName, processGroupRemote);
        localProcessGroups.put(theApplicationName, procesGroupLocal);
      }
      clients.put(theClient, theClientName);
      addSessionListener(theClient);
      notifyClientJoinedRemote(
          processGroupRemote,
          toSerializedProcesstGroups(),
          clients,
          myName,
          theClientName,
          theClient,
          theApplicationName,
          retVal.newSession,
          retVal.newApplication);
      notifyClientJoinedLocal(
          procesGroupLocal,
          toSerializedProcesstGroups(),
          clients,
          myName,
          theClientName,
          theClient,
          theApplicationName,
          retVal.newSession,
          retVal.newApplication);
      Tracer.info(this, "Leaving Session Join");
      // why was this commented out?
      ServerClientJoined.newCase(
          CommunicatorSelector.getProcessName(), theClientName, theApplicationName, myName, this);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return;
  }
Exemplo n.º 5
0
 @Override
 public void send(String clientName, InMessageType message) {
   Tracer.info(this, "Converting single to multiple send");
   Set<String> clientNames = new HashSet();
   clientNames.add(clientName);
   send(clientNames, message);
 }
 public void messageReceived(String aSourceName, Object aMessage) {
   Tracer.info(this, "message Received:" + aMessage);
   //		System.out.println("Message:" + aMessage);
   String oldOutput = output;
   MessageWithSource messageWithSource = (MessageWithSource) aMessage;
   output = (String) messageWithSource.getMessage();
   propertyChangeSupport.firePropertyChange(
       new PropertyChangeEvent(this, "output", oldOutput, output));
 }
Exemplo n.º 7
0
 @Override
 public void send(String clientName, Object message) {
   Tracer.info(this, this + "  serializing message " + message + " to " + clientName);
   try {
     ByteBuffer bbMessage = bufferSerializationSupport.outputBufferFromObject(message);
     destination.send(clientName, bbMessage);
   } catch (RuntimeException e) {
     throw e;
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public static PredictionValueToStatus newCase(String aMessage, Object aFinder) {
    if (Tracer.isPrintInfoEnabled(aFinder)
        || Tracer.isPrintInfoEnabled(PredictionValueToStatus.class))
      EventLoggerConsole.getConsole()
          .getMessageConsoleStream()
          .println("(" + Tracer.infoPrintBody(PredictionValueToStatus.class) + ") " + aMessage);
    if (shouldInstantiate(PredictionValueToStatus.class)) {
      PredictionValueToStatus retVal = new PredictionValueToStatus("", aFinder);
      retVal.announce();
      return retVal;
    }
    Tracer.info(aFinder, aMessage);

    return null;
  }