Examples of Lock


Examples of org.apache.archiva.common.filelock.Lock

    private void moveTempToTarget( File temp, File target )
        throws ProxyException
    {

        // TODO file lock library
        Lock lock = null;
        try
        {
            lock = fileLockManager.writeFileLock( target );
            if ( lock.getFile().exists() && !lock.getFile().delete() )
            {
                throw new ProxyException( "Unable to overwrite existing target file: " + target.getAbsolutePath() );
            }

            lock.getFile().getParentFile().mkdirs();

            if ( !temp.renameTo( lock.getFile() ) )
            {
                log.warn( "Unable to rename tmp file to its final name... resorting to copy command." );

                try
                {
                    FileUtils.copyFile( temp, lock.getFile() );
                }
                catch ( IOException e )
                {
                    if ( lock.getFile().exists() )
                    {
                        log.debug( "Tried to copy file {} to {} but file with this name already exists.",
                                   temp.getName(), lock.getFile().getAbsolutePath() );
                    }
                    else
                    {
                        throw new ProxyException(
                            "Cannot copy tmp file " + temp.getAbsolutePath() + " to its final location", e );
View Full Code Here

Examples of org.apache.aurora.gen.Lock

    locks = new Locks(lockManager);
  }

  @Test
  public void testDumpContents() throws Exception {
    ILock lock = ILock.build(new Lock()
        .setKey(LOCK_KEY.newBuilder())
        .setToken("test token")
        .setMessage("test msg")
        .setUser("test usr")
        .setTimestampMs(325));
View Full Code Here

Examples of org.apache.avalon.excalibur.concurrent.Lock

        throws ComponentException {

  try {
            store = (Store)componentManager.
                lookup( "org.apache.avalon.cornerstone.services.store.Store" );
            lock = new Lock();

        } catch (Exception e) {
            final String message = "Failed to retrieve Store component:" + e.getMessage();
            getLogger().error( message, e );
            throw new ComponentException( message, e );
View Full Code Here

Examples of org.apache.jackrabbit.api.jsr283.lock.Lock

        NodeImpl node = (NodeImpl) session.getNode(absPath);
        if (node.isNew()) {
            while (node.isNew()) {
                node = (NodeImpl) node.getParent();
            }
            Lock l = (Lock) systemLockMgr.getLock(node);
            if (l.isDeep()) {
                return l;
            } else {
                throw new LockException("Node not locked: " + node);
            }
        } else {
View Full Code Here

Examples of org.apache.jackrabbit.ocm.lock.Lock

            checkIfNodeLocked(absPath);

            Node node = getNode(absPath);
            javax.jcr.lock.Lock lock = node.lock(isDeep, isSessionScoped);

            return new Lock(lock);
        } catch (LockException e) {
            // Only one case with LockException remains: if node is not
            // mix:lockable, propably error in custom node types definitions
            throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Node of type is not type mix:lockable", e);
        } catch (RepositoryException e) {
View Full Code Here

Examples of org.apache.james.util.Lock

            streamConfiguration.setAttribute( "type", "STREAM" );
            streamConfiguration.setAttribute( "model", "SYNCHRONOUS" );

            sr = (StreamRepository) store.select(streamConfiguration);
            or = (ObjectRepository) store.select(objectConfiguration);
            lock = new Lock();
            keys = Collections.synchronizedSet(new HashSet());


            //Finds non-matching pairs and deletes the extra files
            HashSet streamKeys = new HashSet();
View Full Code Here

Examples of org.apache.karaf.main.lock.Lock

        config = new ConfigProperties();
        if (config.delayConsoleStart) {
            System.out.println(config.startupMessage);
        }
        BootstrapLogManager.setProperties(config.props);
        Lock lock = createLock();
        KarafLockCallback lockCallback = new KarafLockCallback();
        lockManager = new LockManager(lock, lockCallback, config.lockDelay);
        InstanceHelper.updateInstancePid(config.karafHome, config.karafBase);
        LOG.addHandler(BootstrapLogManager.getDefaultHandler());
View Full Code Here

Examples of org.apache.lenya.transaction.Lock

        } catch (TransactionException e) {
            throw e;
        } catch (Exception e) {
            throw new TransactionException(e);
        }
        this.lock = new Lock(currentVersion);
    }
View Full Code Here

Examples of org.apache.lucene.store.Lock

          String LOCK_FILE = "write.lock";
          String dicHome = p
              .getProperty("paoding.dic.home.absolute.path");
          FSLockFactory FileLockFactory = new NativeFSLockFactory(
              dicHome);
          Lock lock = FileLockFactory.makeLock(LOCK_FILE);

          boolean obtained = false;
          try {
            obtained = lock.obtain(90000);
            if (obtained) {
              // 编译词典-对词典进行可能的处理,以符合分词器的要求
              if (compiler.shouldCompile(p)) {
                Dictionaries dictionaries = readUnCompiledDictionaries(p);
                Paoding tempPaoding = createPaodingWithKnives(p);
                setDictionaries(tempPaoding, dictionaries);
                compiler.compile(dictionaries, tempPaoding, p);
              }

              // 使用编译后的词典
              final Dictionaries dictionaries = compiler
                  .readCompliedDictionaries(p);
              setDictionaries(finalPaoding, dictionaries);

              // 启动字典动态转载/卸载检测器
              // 侦测时间间隔(秒)。默认为60秒。如果设置为0或负数则表示不需要进行检测
              String intervalStr = getProperty(p,
                  Constants.DIC_DETECTOR_INTERVAL);
              int interval = Integer.parseInt(intervalStr);
              if (interval > 0) {
                dictionaries.startDetecting(interval,
                    new DifferenceListener() {
                      public void on(Difference diff)
                          throws Exception {
                        dictionaries.stopDetecting();
                       
                        // 此处调用run方法,以当检测到**编译后**的词典变更/删除/增加时,
                        // 重新编译源词典、重新创建并启动dictionaries自检测
                        run();
                      }
                    });
              }
            }
          } catch (LockObtainFailedException ex) {
            log.error("Obtain " + LOCK_FILE + " in " + dicHome
                + " failed:" + ex.getMessage());
            throw ex;
          } catch (IOException ex) {
            log.error("Obtain " + LOCK_FILE + " in " + dicHome
                + " failed:" + ex.getMessage());
            throw ex;
          } finally {
            if (obtained) {
              try {
                lock.release();
              } catch (Exception ex) {

              }
            }
          }
View Full Code Here

Examples of org.apache.maven.index.fs.Lock

            fetcher.connect( context.getId(), context.getIndexUpdateUrl() );
        }

        File cacheDir = updateRequest.getLocalIndexCacheDir();
        Locker locker = updateRequest.getLocker();
        Lock lock = locker != null && cacheDir != null ? locker.lock( cacheDir ) : null;
        try
        {
            if ( cacheDir != null )
            {
                LocalCacheIndexAdaptor cache = new LocalCacheIndexAdaptor( cacheDir, result );

                if ( !updateRequest.isOffline() )
                {
                    cacheDir.mkdirs();

                    try
                    {
                        fetchAndUpdateIndex( updateRequest, fetcher, cache );
                        cache.commit();
                    }
                    finally
                    {
                        fetcher.disconnect();
                    }
                }

                fetcher = cache.getFetcher();
            }
            else if ( updateRequest.isOffline() )
            {
                throw new IllegalArgumentException( "LocalIndexCacheDir can not be null in offline mode" );
            }

            try
            {
                if ( !updateRequest.isCacheOnly() )
                {
                    LuceneIndexAdaptor target = new LuceneIndexAdaptor( updateRequest );
                    result.setTimestamp( fetchAndUpdateIndex( updateRequest, fetcher, target ) );
                    target.commit();
                }
            }
            finally
            {
                fetcher.disconnect();
            }
        }
        finally
        {
            if ( lock != null )
            {
                lock.release();
            }
        }

        return result;
    }
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.