Examples of tryLock()


Examples of cn.com.manager.domains.Task.tryLock()

    public String execute(ProcessData datas) throws AppException {
        Task task = datas.getTask();
        String result = null;
        boolean capured = false;
        try {
            capured = task.tryLock();
            if (!capured) {
                throw new AppException("E1200001",task.getTaskid());
            }
            //业务处理
            result = this.process(datas.getData());
View Full Code Here

Examples of com.alibaba.otter.shared.arbitrate.impl.zookeeper.lock.DistributedLock.tryLock()

    protected NormalTerminProcess    normalTerminProcess;

    public boolean process(TerminEventData data) {
        DistributedLock lock = new DistributedLock(StagePathUtils.getLoadLock(data.getPipelineId()));
        try {
            boolean locked = lock.tryLock();// 尝试进行锁定,等待当前的load操作完成
            if (!locked) {
                return false;
            }
            processChain(data);
            return true;
View Full Code Here

Examples of com.alibaba.otter.shared.arbitrate.impl.zookeeper.lock.DistributedReentrantLock.tryLock()

        for (int i = 0; i < count; i++) {
            exeucotr.submit(new Runnable() {

                public void run() {
                    try {
                        while (lock.tryLock() == false) {
                            Thread.sleep(100 + RandomUtils.nextInt(100));
                        }

                        System.out.println("id: " + lock.getId() + " is leader: " + lock.isOwner());
                    } catch (InterruptedException e) {
View Full Code Here

Examples of com.alimama.mdrill.utils.TryLockFile.trylock()

  {
    String path=null;
    TryLockFile lock=null;
    try{
      lock=new TryLockFile(HigoJoinUtils.pathForLock(req, tablename));
      lock.trylock();
      path=pathToLocal(req, tablename);
    }finally{
      if(lock!=null)
      {
        lock.unlock();
View Full Code Here

Examples of com.google.jstestdriver.SlaveBrowser.tryLock()

            RunnerType.CLIENT, BrowserState.CAPTURED, new Instant(0));
    browsers.addSlave(browserTwo);
    final BrowserReaper browserReaper = new BrowserReaper(browsers);
    time.add(40);
    browserOne.heartBeat();
    browserTwo.tryLock("locked");
    browserReaper.run();
    assertEquals(2, browsers.getBrowsers().size());
  }
}
View Full Code Here

Examples of com.hazelcast.core.ILock.tryLock()

        lock.lock();

        Runnable tryLockRunnable = new Runnable() {
            public void run() {
                if (lock.tryLock()) {
                    atomicInteger.incrementAndGet();
                }
            }
        };
View Full Code Here

Examples of com.hazelcast.core.IMap.tryLock()

//        }, 1);
        addOperation(operations, new Runnable() {
            public void run() {
                IMap map = hazelcast.getMap("myMap");
                int key = random.nextInt(SIZE);
                boolean locked = map.tryLock(key);
                if (locked) {
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
View Full Code Here

Examples of com.hazelcast.core.MultiMap.tryLock()

    @Test
    public void testTryLock() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        Object key = "key";
        assertTrue(mm.tryLock(key));
    }

    @Test(expected = NullPointerException.class)
    public void testTryLock_whenNullKey() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
View Full Code Here

Examples of com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynchClient.tryLock()

      } else if (!network.isConnected()) {
        // DISCONNECTED NETWORK, GET ANOTHER ONE
        OLogManager.instance().error(this, "Removing disconnected network channel '%s'...", lastURL);
        engine.getConnectionManager().remove(network);
        network = null;
      } else if (!network.tryLock()) {
        // CANNOT LOCK IT, MAYBE HASN'T BE CORRECTLY UNLOCKED BY PREVIOUS USER
        OLogManager.instance().error(this, "Removing locked network channel '%s'...", lastURL);
        engine.getConnectionManager().remove(network);
        network = null;
      }
View Full Code Here

Examples of com.packtpub.java7.concurrency.chapter7.recipe08.task.MyLock.tryLock()

     * The main thread also tries to get the lock
     */
    boolean value;
    do {
      try {
        value=lock.tryLock(1,TimeUnit.SECONDS);
        if (!value) {
          System.out.printf("Main: Trying to get the Lock\n");
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.