Package org.apache.commons.lang.mutable

Examples of org.apache.commons.lang.mutable.MutableInt


   * @param curTask task to submit
   * @param curTaskZKVersion current version of task
   */
  void submitTask(final String curTask, final RecoveryMode mode, final int curTaskZKVersion,
      final int reportPeriod) {
    final MutableInt zkVersion = new MutableInt(curTaskZKVersion);

    CancelableProgressable reporter = new CancelableProgressable() {
      private long last_report_at = 0;

      @Override
      public boolean progress() {
        long t = EnvironmentEdgeManager.currentTime();
        if ((t - last_report_at) > reportPeriod) {
          last_report_at = t;
          int latestZKVersion =
              attemptToOwnTask(false, watcher, server.getServerName(), curTask,
                mode, zkVersion.intValue());
          if (latestZKVersion < 0) {
            LOG.warn("Failed to heartbeat the task" + curTask);
            return false;
          }
          zkVersion.setValue(latestZKVersion);
        }
        return true;
      }
    };
    ZkSplitLogWorkerCoordination.ZkSplitTaskDetails splitTaskDetails =
View Full Code Here


    for (Entry<ByteBuffer,
        ? extends Collection<LoadQueueItem>> e: regionGroups.asMap().entrySet()) {
      final Collection<LoadQueueItem> lqis =  e.getValue();
      HashMap<byte[], MutableInt> filesMap = new HashMap<byte[], MutableInt>();
      for (LoadQueueItem lqi: lqis) {
        MutableInt count = filesMap.get(lqi.family);
        if (count == null) {
          count = new MutableInt();
          filesMap.put(lqi.family, count);
        }
        count.increment();
        if (count.intValue() > maxFilesPerRegionPerFamily) {
          LOG.error("Trying to load more than " + maxFilesPerRegionPerFamily
            + " hfiles to family " + Bytes.toStringBinary(lqi.family)
            + " of region with start key "
            + Bytes.toStringBinary(e.getKey()));
          return false;
View Full Code Here

    try {
      if (started) {
        return;
      }

      final MutableInt waitingFor = new MutableInt(1);
      final Object waitingForMonitor = new Object();

      // Add listener for creation/deletion of workers
      workerPathCache.getListenable().addListener(
          new PathChildrenCacheListener()
          {
            @Override
            public void childEvent(CuratorFramework client, final PathChildrenCacheEvent event) throws Exception
            {
              final Worker worker;
              switch (event.getType()) {
                case CHILD_ADDED:
                  worker = jsonMapper.readValue(
                      event.getData().getData(),
                      Worker.class
                  );
                  synchronized (waitingForMonitor) {
                    waitingFor.increment();
                  }
                  Futures.addCallback(
                      addWorker(worker),
                      new FutureCallback<ZkWorker>()
                      {
                        @Override
                        public void onSuccess(ZkWorker zkWorker)
                        {
                          synchronized (waitingForMonitor) {
                            waitingFor.decrement();
                            waitingForMonitor.notifyAll();
                          }
                        }

                        @Override
                        public void onFailure(Throwable throwable)
                        {
                          synchronized (waitingForMonitor) {
                            waitingFor.decrement();
                            waitingForMonitor.notifyAll();
                          }
                        }
                      }
                  );
                  break;
                case CHILD_UPDATED:
                  worker = jsonMapper.readValue(
                      event.getData().getData(),
                      Worker.class
                  );
                  updateWorker(worker);
                  break;

                case CHILD_REMOVED:
                  worker = jsonMapper.readValue(
                      event.getData().getData(),
                      Worker.class
                  );
                  removeWorker(worker);
                  break;
                case INITIALIZED:
                  synchronized (waitingForMonitor) {
                    waitingFor.decrement();
                    waitingForMonitor.notifyAll();
                  }
                default:
                  break;
              }
            }
          }
      );
      workerPathCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
      synchronized (waitingForMonitor) {
        while (waitingFor.intValue() > 0) {
          waitingForMonitor.wait();
        }
      }
      started = true;
    }
View Full Code Here

    for (Entry<ByteBuffer,
        ? extends Collection<LoadQueueItem>> e: regionGroups.asMap().entrySet()) {
      final Collection<LoadQueueItem> lqis =  e.getValue();
      HashMap<byte[], MutableInt> filesMap = new HashMap<byte[], MutableInt>();
      for (LoadQueueItem lqi: lqis) {
        MutableInt count = filesMap.get(lqi.family);
        if (count == null) {
          count = new MutableInt();
          filesMap.put(lqi.family, count);
        }
        count.increment();
        if (count.intValue() > maxFilesPerRegionPerFamily) {
          LOG.error("Trying to load more than " + maxFilesPerRegionPerFamily
            + " hfiles to family " + Bytes.toStringBinary(lqi.family)
            + " of region with start key "
            + Bytes.toStringBinary(e.getKey()));
          return false;
View Full Code Here

    for (Entry<ByteBuffer,
        ? extends Collection<LoadQueueItem>> e: regionGroups.asMap().entrySet()) {
      final Collection<LoadQueueItem> lqis =  e.getValue();
      HashMap<byte[], MutableInt> filesMap = new HashMap<byte[], MutableInt>();
      for (LoadQueueItem lqi: lqis) {
        MutableInt count = filesMap.get(lqi.family);
        if (count == null) {
          count = new MutableInt();
          filesMap.put(lqi.family, count);
        }
        count.increment();
        if (count.intValue() > maxFilesPerRegionPerFamily) {
          LOG.error("Trying to load more than " + maxFilesPerRegionPerFamily
            + " hfiles to family " + Bytes.toStringBinary(lqi.family)
            + " of region with start key "
            + Bytes.toStringBinary(e.getKey()));
          return false;
View Full Code Here

    @Test
    @Ignore("MULE-6926: flaky test")
    public void testInboundEndpointMaxRedeliveryTakesPrecendence() throws Exception
    {
        final CountDownLatch latch = new CountDownLatch(EXPECTED_DELIVERED_TIMES);
        final MutableInt deliveredTimes = new MutableInt(0);
        LocalMuleClient client = muleContext.getClient();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>() {
            @Override
            public void onNotification(ExceptionNotification notification)
            {
                deliveredTimes.increment();
                latch.countDown();
            }
        });
        client.dispatch("vm://in4","some message",null);
        if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS))
        {
            fail("message should have been delivered at least 5 times");
        }
        assertThat(deliveredTimes.intValue(),is(EXPECTED_DELIVERED_TIMES));
    }
View Full Code Here

    @Test
    @Ignore("MULE-6926: flaky test")
    public void testRedeliveryExhaustedTransactional() throws Exception
    {
        final CountDownLatch latch = new CountDownLatch(EXPECTED_DELIVERED_TIMES);
        final MutableInt deliveredTimes = new MutableInt(0);
        LocalMuleClient client = muleContext.getClient();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>() {
            @Override
            public void onNotification(ExceptionNotification notification)
            {
                deliveredTimes.increment();
                latch.countDown();
            }
        });
        client.dispatch("jms://in2?connector=activeMq", MESSAGE,null);
        if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS))
        {
            fail("message should have been delivered at least 5 times");
        }
        assertThat(deliveredTimes.intValue(), is(EXPECTED_DELIVERED_TIMES));
        MuleMessage dlqMessage = client.request("jms://dlq?connector=activeMq", TIMEOUT);
        assertThat(dlqMessage, IsNull.<Object>notNullValue());
        assertThat(dlqMessage.getPayloadAsString(), is(MESSAGE_EXPECTED));
    }
View Full Code Here

    @Test
    public void testRedeliveryExhaustedNoTransaction() throws Exception
    {
        final CountDownLatch latch = new CountDownLatch(EXPECTED_DELIVERED_TIMES);
        final MutableInt deliveredTimes = new MutableInt(0);
        LocalMuleClient client = muleContext.getClient();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>() {
            @Override
            public void onNotification(ExceptionNotification notification)
            {
                deliveredTimes.increment();
                latch.countDown();
            }
        });
        client.dispatch("jms://in3?connector=activeMq", MESSAGE, null);
        if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS))
        {
            fail("message should have been delivered at least 5 times");
        }
        assertThat(deliveredTimes.intValue(), is(EXPECTED_DELIVERED_TIMES));
        MuleMessage dlqMessage = client.request("jms://dlq?connector=activeMq", TIMEOUT);
        assertThat(dlqMessage, IsNull.<Object>notNullValue());
        assertThat(dlqMessage.getPayloadAsString(), is(MESSAGE_EXPECTED));
    }
View Full Code Here

    @Test
    @Ignore("MULE-6926: flaky test")
    public void testRedeliveryPolicyRedefinition() throws Exception
    {
        final CountDownLatch latch = new CountDownLatch(EXPECTED_DELIVERED_TIMES);
        final MutableInt deliveredTimes = new MutableInt(0);
        LocalMuleClient client = muleContext.getClient();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>() {
            @Override
            public void onNotification(ExceptionNotification notification)
            {
                deliveredTimes.increment();
                latch.countDown();
            }
        });
        client.dispatch("vm://in3","some message",null);
        if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS))
        {
            fail("message should have been delivered at least 5 times");
        }
        assertThat(deliveredTimes.intValue(),is(EXPECTED_DELIVERED_TIMES));
    }
View Full Code Here

      if (ZKSplitLog.isRescanNode(watcher, currentTask)) {
        ZkSplitLogWorkerCoordination.ZkSplitTaskDetails splitTaskDetails =
            new ZkSplitLogWorkerCoordination.ZkSplitTaskDetails();
        splitTaskDetails.setTaskNode(currentTask);
        splitTaskDetails.setCurTaskZKVersion(new MutableInt(currentVersion));

        endTask(new SplitLogTask.Done(server.getServerName(), slt.getMode()),
          SplitLogCounters.tot_wkr_task_acquired_rescan, splitTaskDetails);
        return;
      }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.mutable.MutableInt

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.