Package org.jboss.errai.otec.client

Examples of org.jboss.errai.otec.client.OTEntity


//          + ";rev" + queuedOp.getOperation().getRevision() + ";entity:" + queuedOp.getEntityId());

      handleOperation(queuedOp);
    }
    catch (BadSync sync) {
      final OTEntity entity = getEntityStateSpace().getEntity(sync.getEntityId());

      getPeerState().getPeer(sync.getAgentId())
          .forceResync(sync.getEntityId(), entity.getRevision(), String.valueOf(entity.getState().get()));
    }
    catch (Throwable t) {
      t.printStackTrace();
    }
    return true;
View Full Code Here


          final Integer entityId = message.get(Integer.class, "EntityId");

          peer.setLastKnownRemoteSequence(entityId, purgeHint);
        }
        else if (value != null) {
          final OTEntity entity = engine.getEntityStateSpace().getEntity(value.getEntityId());
          if (entity == null) {
            return;
          }
          synchronized (entity) {
            ClientDemuxer demux = LocalContext.get(queueSession).getAttribute(ClientDemuxer.class);
            if (demux == null) {
              LocalContext.get(queueSession).setAttribute(ClientDemuxer.class, demux = new ClientDemuxer());
            }

         //   final Collection<OpDto> enginePlanFor = demux.getEnginePlanFor(value);
            for (final OpDto operation : Collections.singletonList(value)) {

              final OTOperation remoteOp = operation.otOperation(engine);

              OTLogUtil.log("RECV", "<<from: " + remoteOp.getAgentId() + ">>" ,
                  "REMOTE", "Server", operation.getRevision(),
                  "\"" + String.valueOf(entity.getState().get()) + "\"");

              if (!engine.receive(session, remoteOp)) {
                System.out.println("*** WARNING: CORRUPT PATHS - MUST RESYNC ALL ***");
                engine.getPeerState().forceResyncAll(entity);
              }
            }
          }
        }
      }
    });

    messageBus.subscribe("ServerOTEngineSyncService", new MessageCallback() {
      @Override
      public void callback(final Message message) {
        final Integer entityId = message.getValue(Integer.class);

        final QueueSession queueSession = message.getResource(QueueSession.class, "Session");
        final String session = queueSession.getSessionId();

        OTPeer peer = engine.getPeerState().getPeer(session);
        if (peer == null) {
          engine.getPeerState().registerPeer(peer = new ServerOTPeerImpl(session, messageBus));

          final OTPeer _peer = peer;

          LaundryListProviderFactory.get()
              .getLaundryList(queueSession)
              .add(new Laundry() {
                @Override
                public void clean() throws Exception {
                  engine.getPeerState().deregisterPeer(_peer);
                }
              });
        }

        engine.getPeerState().associateEntity(peer, entityId);

        System.out.println("Peer Register: " + session);

        if (message.hasPart("SyncAck")) {
          System.out.println("RECEIVED SYNC ACK");
          ((ServerOTPeerImpl) peer).setSynced(true);
        }
        else {
          final OTEntity entity = engine.getEntityStateSpace().getEntity(entityId);
          MessageBuilder.createConversation(message)
              .subjectProvided()
              .withValue(entity.getState().get())
              .with("EntityID", entity.getId())
              .with("revision", entity.getRevision())
              .noErrorHandling().reply();
        }
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.jboss.errai.otec.client.OTEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.