Package com.opengamma.transport

Examples of com.opengamma.transport.DirectFudgeConnection


  private static final long TIMEOUT = Timeout.standardTimeoutMillis();

  public void simpleInvocation() {
    final JobDispatcher jobDispatcher = new JobDispatcher();
    final Ready initialMessage = new Ready(1, "Test");
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final RemoteNodeJobInvoker jobInvoker = new RemoteNodeJobInvoker(Executors.newCachedThreadPool(), initialMessage, conduit.getEnd1(), new InMemoryIdentifierMap(), new FunctionCosts(),
        new DummyFunctionBlacklistQuery(), new DummyFunctionBlacklistMaintainer());
    jobDispatcher.registerJobInvoker(jobInvoker);
    final TestJobResultReceiver resultReceiver = new TestJobResultReceiver();
    final FudgeConnection remoteNode = conduit.getEnd2();
    remoteNode.setFudgeMessageReceiver(new FudgeMessageReceiver() {
      @Override
      public void messageReceived(FudgeContext fudgeContext, FudgeMsgEnvelope msgEnvelope) {
        final FudgeDeserializer dcontext = new FudgeDeserializer(fudgeContext);
        s_logger.debug("message = {}", msgEnvelope.getMessage());
View Full Code Here


  }

  public void saturate() {
    final JobDispatcher jobDispatcher = new JobDispatcher();
    final Ready initialMessage = new Ready(3, "Test");
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final RemoteNodeJobInvoker jobInvoker = new RemoteNodeJobInvoker(Executors.newCachedThreadPool(), initialMessage, conduit.getEnd1(), new InMemoryIdentifierMap(), new FunctionCosts(),
        new DummyFunctionBlacklistQuery(), new DummyFunctionBlacklistMaintainer());
    jobDispatcher.registerJobInvoker(jobInvoker);
    final FudgeConnection remoteNode = conduit.getEnd2();
    final Random rnd = new Random();
    remoteNode.setFudgeMessageReceiver(new FudgeMessageReceiver() {
      @Override
      public void messageReceived(FudgeContext fudgeContext, FudgeMsgEnvelope msgEnvelope) {
        final FudgeDeserializer dcontext = new FudgeDeserializer(fudgeContext);
View Full Code Here

  @Test(timeOut = 10000l)
  public void singleThreadSpecLookupDifferentIdentifierValues() {
    InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
    ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
    DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
    RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
    conduit.connectEnd2(server);
    IdentifierMap identifierMap = new RemoteIdentifierMap(client);

    final ValueSpecification[] valueSpec = new ValueSpecification[10];
    for (int i = 0; i < valueSpec.length; i++) {
      valueSpec[i] = new ValueSpecification("Test Value", ComputationTargetSpecification.of(UniqueId.of("Kirk", "Value" + i)),
View Full Code Here

  @Test(timeOut = 10000l)
  public void singleThreadLookupDifferentIdentifierValuesRepeated() {
    InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
    ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
    DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
    conduit.connectEnd2(server);
    RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
    IdentifierMap identifierMap = new RemoteIdentifierMap(client);

    Map<String, Long> _idsByValueName = new HashMap<String, Long>();
    for (int i = 0; i < 10; i++) {
      String valueName = "Value" + i;
View Full Code Here

  @Test(timeOut = 30000l)
  public void multiThreadLookupDifferentIdentifierValuesRepeatedSharedClient() throws InterruptedException {
    InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
    ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
    DirectFudgeConnection conduit1 = new DirectFudgeConnection(cache.getFudgeContext());
    conduit1.connectEnd2(server);
    DirectFudgeConnection conduit2 = new DirectFudgeConnection(cache.getFudgeContext());
    conduit2.connectEnd2(server);
    final RemoteCacheClient client = new RemoteCacheClient(conduit1.getEnd1(), conduit2.getEnd1());
    final IdentifierMap identifierMap = new RemoteIdentifierMap(client);

    final ConcurrentMap<String, Long> _idsByValueName = new ConcurrentHashMap<String, Long>();
    final Random rand = new Random();
    final AtomicBoolean failed = new AtomicBoolean(false);
View Full Code Here

    final ConcurrentMap<String, Long> _idsByValueName = new ConcurrentHashMap<String, Long>();
    final Random rand = new Random();
    final AtomicBoolean failed = new AtomicBoolean(false);
    List<Thread> threads = new ArrayList<Thread>();
    for (int i = 0; i < 10; i++) {
      final DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
      conduit.connectEnd2(server);
      Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
          final RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
          final IdentifierMap identifierMap = new RemoteIdentifierMap(client);
          try {
            for (int j = 0; j < 1000; j++) {
              int randomValue = rand.nextInt(100);
              String valueName = "Value" + randomValue;
View Full Code Here

  // @Test(timeout=10000l)
  @Test
  public void singleThreadPutLoad() throws InterruptedException {
    InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
    ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
    DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
    conduit.connectEnd2(server);
    RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
    FudgeMessageStore dataStore = new RemoteFudgeMessageStore(client, new ViewComputationCacheKey(UniqueId.of("Test", "ViewCycle1"), "Config1"));

    // Single value
    final MutableFudgeMsg inputValue1 = s_fudgeContext.newMessage();
    for (int i = 0; i < 32; i++) {
View Full Code Here

  @Test(timeOut = 10000l)
  public void singleThreadPutLoadPurgeLoad() throws InterruptedException {
    InMemoryViewComputationCacheSource cache = new InMemoryViewComputationCacheSource(s_fudgeContext);
    ViewComputationCacheServer server = new ViewComputationCacheServer(cache);
    DirectFudgeConnection conduit = new DirectFudgeConnection(cache.getFudgeContext());
    conduit.connectEnd2(server);
    RemoteCacheClient client = new RemoteCacheClient(conduit.getEnd1());
    FudgeMessageStore dataStore = new RemoteFudgeMessageStore(client, new ViewComputationCacheKey(
        UniqueId.of("Test", "ViewCycle1"), "Config1"));
    final MutableFudgeMsg inputValue = s_fudgeContext.newMessage();
    for (int i = 0; i < 32; i++) {
      inputValue.add(i, Integer.toString(i));
View Full Code Here

    return new CalculationJob(JobDispatcherTest.createTestJobSpec(), 0L, VersionCorrection.LATEST, null, JobDispatcherTest.createTestJobItems(), CacheSelectHint.allShared());
  }

  public void simpleInvocation() {
    final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
    conduit.getEnd2().setFudgeMessageReceiver(messages);
    final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
    final SimpleCalculationNode node = new TestCalculationNode();
    assertEquals(0, messages.getMessages().size());
    client.addNode(node);
    assertEquals(0, messages.getMessages().size());
    client.start();
    assertEquals(1, messages.getMessages().size());
    final FudgeMsgEnvelope readyMsgEnvelope = messages.getMessages().get(0);
    messages.clear();
    final FudgeDeserializer dcontext = new FudgeDeserializer(s_fudgeContext);
    final FudgeSerializer scontext = new FudgeSerializer(s_fudgeContext);
    final RemoteCalcNodeMessage readyMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, readyMsgEnvelope.getMessage());
    assertTrue(readyMessage instanceof Ready);
    final Ready ready = (Ready) readyMessage;
    assertEquals(1, ready.getCapacity());
    conduit.getEnd2 ().getFudgeMessageSender().send (FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg (new Init(0)), Init.class, RemoteCalcNodeMessage.class));
    final CalculationJob job = createTestCalculationJob();
    AbstractIdentifierMap.convertIdentifiers(identifierMap, job);
    conduit.getEnd2().getFudgeMessageSender().send(
        FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg(new Execute(job)), Execute.class, RemoteCalcNodeMessage.class));
    final FudgeMsgEnvelope resultMsgEnvelope = messages.waitForMessage(TIMEOUT);
    assertNotNull(resultMsgEnvelope);
    final RemoteCalcNodeMessage resultMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, resultMsgEnvelope.getMessage());
    assertTrue(resultMessage instanceof Result);
View Full Code Here

    assertEquals(job.getSpecification(), result.getResult().getSpecification());
  }
 
  public void isAlive () {
    final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
    conduit.getEnd2().setFudgeMessageReceiver(messages);
    final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
    client.start();
    assertEquals(1, messages.getMessages().size());
    final FudgeMsgEnvelope readyMsgEnvelope = messages.getMessages().get(0);
    messages.clear();
    final FudgeDeserializer dcontext = new FudgeDeserializer(s_fudgeContext);
    final FudgeSerializer scontext = new FudgeSerializer(s_fudgeContext);
    final RemoteCalcNodeMessage readyMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, readyMsgEnvelope.getMessage());
    assertTrue(readyMessage instanceof Ready);
    conduit.getEnd2 ().getFudgeMessageSender().send (FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg (new Init(0)), Init.class, RemoteCalcNodeMessage.class));
    final CalculationJob job1 = createTestCalculationJob();
    final CalculationJob job2 = createTestCalculationJob();
    AbstractIdentifierMap.convertIdentifiers(identifierMap, job1);
    conduit.getEnd2().getFudgeMessageSender().send(FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg(new Execute(job1)), Execute.class, RemoteCalcNodeMessage.class));
    conduit.getEnd2().getFudgeMessageSender().send(FudgeSerializer.addClassHeader(scontext.objectToFudgeMsg(new IsAlive(Arrays.asList (job1.getSpecification (), job2.getSpecification ()))), IsAlive.class, RemoteCalcNodeMessage.class));
    final FudgeMsgEnvelope resultMsgEnvelope = messages.waitForMessage(TIMEOUT);
    assertNotNull(resultMsgEnvelope);
    final RemoteCalcNodeMessage failureMessage = dcontext.fudgeMsgToObject(RemoteCalcNodeMessage.class, resultMsgEnvelope.getMessage());
    assertTrue(failureMessage instanceof Failure);
    final Failure failure = (Failure) failureMessage;
View Full Code Here

TOP

Related Classes of com.opengamma.transport.DirectFudgeConnection

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.