Package com.nokia.dempsy.cluster

Examples of com.nokia.dempsy.cluster.ClusterInfoSession


               try
               {
                  DempsyExecutor executor = (DempsyExecutor)clusterDefinition.getExecutor(); // this can be null
                  if (executor != null)
                     executor.start();
                  ClusterInfoSession clusterSession = clusterSessionFactory.createSession();
                  ClusterId currentClusterId = clusterDefinition.getClusterId();
                  router = new Router(clusterDefinition.getParentApplicationDefinition());
                  router.setCurrentCluster(currentClusterId);
                  router.setClusterSession(clusterSession);
                  // get the executor if one is set
View Full Code Here


      final DefaultRouterSlotInfo newSlot = (DefaultRouterSlotInfo)originalSession.getData(shardPath, null);

      final AtomicBoolean stillRunning = new AtomicBoolean(true);
      final AtomicBoolean failed = new AtomicBoolean(false);

      final ClusterInfoSession session = factory.createSession();
     
      Runnable slotGrabber = new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
               boolean haveSlot = false;
               while (!haveSlot && stillRunning.get())
               {
                  newSlot.setDestination(new JunkDestination());
                  if (session.mkdir(shardPath,newSlot,DirMode.EPHEMERAL) != null)
                     haveSlot = true;
                  Thread.yield();
               }
            }
            catch(ClusterInfoException e) { failed.set(true)}
            catch(RuntimeException re)
            {
               re.printStackTrace();
               failed.set(true);
            }
            finally { stillRunning.set(false); }
         }
      };

      try
      {
         new Thread(slotGrabber).start();

         boolean onStandby = false;
         long startTime = System.currentTimeMillis();
         while (!onStandby && timeoutmillis >= (System.currentTimeMillis() - startTime))
         {
            ((DisruptibleSession)originalSession).disrupt();
            Thread.sleep(100);
            if (!stillRunning.get())
               onStandby = true;
         }

         assertTrue(onStandby);
         assertFalse(failed.get());
      }
      catch (InterruptedException ie) { session.stop(); throw ie; }
      catch (Error cie) { session.stop(); throw cie; }
      finally { stillRunning.set(false); }

      return session;
   }
View Full Code Here

                 
                  assertEquals(adaptor.lastSent,message);
                  assertEquals(adaptor.lastSent,mp.lastReceived.get());
                 
                  // now go into a disruption loop
                  ClusterInfoSession session = TestUtils.getSession(dempsy.getCluster(new ClusterId("test-app","test-cluster1")));
                  assertNotNull(session);
                  DisruptibleSession dsess = (DisruptibleSession) session;
                 
                  final AtomicBoolean stopSending = new AtomicBoolean(false);
                 
View Full Code Here

      Checker checker = new Checker()  
      {
         @Override
         public void check(ApplicationContext context) throws Throwable
         {
            ClusterInfoSession session = null;
           
            try
            {
               // start things and verify that the init method was called
               Dempsy dempsy = (Dempsy)context.getBean("dempsy");
               TestMp mp = (TestMp) getMp(dempsy, "test-app","test-cluster1");
               final ClusterId clusterId = new ClusterId("test-app","test-cluster1");

               // verify we haven't called it again, not that there's really
               // a way to given the code
               assertEquals(1, mp.startCalls.get());

               // make sure that there are no Mps
               MetricGetters statsCollector = (MetricGetters)dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).getStatsCollector();

               // This will wait until the keySpace is up to the maxcount which is set (in the setup, below) to 100000
               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     {  return 100000 == sc.getMessageProcessorCount(); } }));

               // now push the cluster into backup node.
               ClusterInfoSession originalSession = dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).retouRteg().getClusterSession();
               ClusterInfoSessionFactory factory = dempsy.getClusterSessionFactory();

               session = TestUtils.stealShard(originalSession, factory, clusterId.asPath() + "/" + String.valueOf(0),baseTimeoutMillis);

               // If we got here then the MpContainer is on standby and the number of Mps should
View Full Code Here

      Checker checker = new Checker()  
      {
         @Override
         public void check(ApplicationContext context) throws Throwable
         {
            ClusterInfoSession session = null;
           
            try
            {
               // start things and verify that the init method was called
               Dempsy dempsy = (Dempsy)context.getBean("dempsy");
               TestMp mp = (TestMp) getMp(dempsy, "test-app","test-cluster1");
               final ClusterId clusterId = new ClusterId("test-app","test-cluster1");

               // verify we haven't called it again, not that there's really
               // a way to given the code
               assertEquals(1, mp.startCalls.get());

               // make sure that there are no Mps
               MetricGetters statsCollector = (MetricGetters)dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).getStatsCollector();

               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     {  return 100000 == sc.getMessageProcessorCount(); } }));
              
               // now there's 100000 mps in the container created from the KeySource. So we steal the
               // shard and force if offline but continuously disrupt it while it tries to come
               // back up.

               // now push the cluster into backup node.
               ClusterInfoSession originalSession = dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).retouRteg().getClusterSession();
               ClusterInfoSessionFactory factory = dempsy.getClusterSessionFactory();

               String path = clusterId.asPath() + "/" + String.valueOf(0);
               session = TestUtils.stealShard(originalSession, factory, path,baseTimeoutMillis);
               DefaultRouterSlotInfo si = (DefaultRouterSlotInfo)session.getData(path, null);
View Full Code Here

      cd.setMessageProcessorPrototype(new GoodTestMp());
      app.add(cd);
      app.initialize();
     
      LocalClusterSessionFactory mpfactory = new LocalClusterSessionFactory();
      ClusterInfoSession session = mpfactory.createSession();
     
      TestUtils.createClusterLevel(clusterId, session);

      // fake the inbound side setup
      inbound = strategy.createInbound(session,clusterId,
View Full Code Here

      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "testDempsy/Dempsy.xml", "testDempsy/ClusterInfo-LocalActx.xml", "testDempsy/Serializer-KryoActx.xml",
            "testDempsy/Transport-PassthroughActx.xml", "testDempsy/SimpleMultistageApplicationActx.xml" );
      Dempsy dempsy = (Dempsy)context.getBean("dempsy");
      ClusterInfoSessionFactory factory = dempsy.getClusterSessionFactory();
      ClusterInfoSession session = factory.createSession();
      ClusterId curCluster = new ClusterId("test-app", "test-cluster1");
      TestUtils.createClusterLevel(curCluster, session);
      session.setData(curCluster.asPath(), new DecentralizedRoutingStrategy.DefaultRouterClusterInfo(20,2));
      session.stop();
      dempsy.stop();
   }
View Full Code Here

                  @Override
                  public synchronized ClusterInfoSession createSession() throws ClusterInfoException
                  {
                     sessionCount++;
                     ClusterInfoSession ret = super.createSession();

                     if (sessionCount == 2)
                        zookeeperCluster = (ZookeeperSession)ret;
                     return ret;
                  }
View Full Code Here

                  @Override
                  public synchronized ClusterInfoSession createSession() throws ClusterInfoException
                  {
                     sessionCount++;
                     ClusterInfoSession ret = super.createSession();

                     if (sessionCount == 2)
                        zookeeperCluster = (ZookeeperSession)ret;
                     return ret;
                  }
View Full Code Here

TOP

Related Classes of com.nokia.dempsy.cluster.ClusterInfoSession

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.