Examples of Lock


Examples of org.geoserver.wfs.request.Lock

            lockRequest.setLockActionAll();
           
            for (int i = 0; i < queries.size(); i++) {
                Query query = queries.get(i);

                Lock lock = lockRequest.createLock();
                lock.setFilter(query.getFilter());
                lock.setHandle(query.getHandle());

                //TODO: joins?
                List<QName> typeNames = query.getTypeNames();
                lock.setTypeName(typeNames.get(0));
                lockRequest.addLock(lock);
            }

            LockFeature lockFeature = new LockFeature(wfs, catalog);
            lockFeature.setFilterFactory(filterFactory);
View Full Code Here

Examples of org.geowebcache.locks.LockProvider.Lock

            log.info("### Old gridset: " + oldGridSet);
            log.info("### New gridset: " + newGridSet);
        }

        Map<TileLayer, GridSubset> affectedLayers = new HashMap<TileLayer, GridSubset>();
        Lock lock = null;
        try {
            lock = lockProvider.getLock(GLOBAL_LOCK_KEY);

            for (TileLayer layer : getTileLayers()) {
                GridSubset gridSubet;
                if (null != (gridSubet = layer.getGridSubset(oldGridSetName))) {
                    affectedLayers.put(layer, gridSubet);
                    layer.removeGridSubset(oldGridSetName);
                    if (needsTruncate) {
                        deleteCacheByGridSetId(layer.getName(), oldGridSetName);
                    }
                }
            }

            // now no layer is referencing it

            XMLConfiguration mainConfig = getXmlConfiguration();

            mainConfig.removeGridset(oldGridSetName);
            mainConfig.addOrReplaceGridSet(new XMLGridSet(newGridSet));
            mainConfig.save();
            getGridSetBroker().remove(oldGridSetName);
            getGridSetBroker().put(newGridSet);

            // tld.removeGridset(oldGridSetName);
            // tld.addGridSet(newGridSet);
            // if (isRename && !needsTruncate) {
            // // /TODO: quotaStore.renameGridSet(oldGridSetName, newGidSetName);
            // }

            final boolean sameSRS = oldGridSet.getSrs().equals(newGridSet.getSrs());

            final int maxZoomLevel = newGridSet.getNumLevels() - 1;

            Set<Configuration> saveConfigurations = new HashSet<Configuration>();

            // now restore the gridsubset for each layer
            for (Map.Entry<TileLayer, GridSubset> entry : affectedLayers.entrySet()) {
                TileLayer layer = entry.getKey();
                GridSubset gsubset = entry.getValue();

                BoundingBox gridSetExtent = gsubset.getOriginalExtent();
                if (null != gridSetExtent && sameSRS) {
                    gridSetExtent = newGridSet.getOriginalExtent().intersection(gridSetExtent);
                }

                int zoomStart = gsubset.getZoomStart();
                int zoomStop = gsubset.getZoomStop();

                if (zoomStart > maxZoomLevel) {
                    zoomStart = maxZoomLevel;
                }
                if (zoomStop > maxZoomLevel || zoomStop < zoomStart) {
                    zoomStop = maxZoomLevel;
                }

                GridSubset newGridSubset = GridSubsetFactory.createGridSubSet(newGridSet,
                        gridSetExtent, zoomStart, zoomStop);

                layer.removeGridSubset(oldGridSetName);
                layer.addGridSubset(newGridSubset);

                Configuration config = tld.getConfiguration(layer);
                config.modifyLayer(layer);
                saveConfigurations.add(config);
            }

            for (Configuration config : saveConfigurations) {
                config.save();
            }
        } finally {
            if(lock != null) {
                lock.release();
            }
        }
    }
View Full Code Here

Examples of org.kiji.schema.util.Lock

   * @throws KeeperException on ZooKeeper error.
   */
  public void update() throws IOException, KeeperException {
    final KijiMetaTable metaTable = mKiji.getMetaTable();

    final Lock lock = ZooKeeperUtils.newTableLayoutLock(mZKClient, mTableURI);
    lock.lock();
    try {
      final NavigableMap<Long, KijiTableLayout> layoutMap =
          metaTable.getTimedTableLayoutVersions(mTableURI.getTable(), Integer.MAX_VALUE);

      final KijiTableLayout currentLayout = layoutMap.lastEntry().getValue();
      final TableLayoutDesc update = mLayoutUpdate.apply(currentLayout);
      if (!Objects.equal(currentLayout.getDesc().getLayoutId(), update.getReferenceLayout())) {
        throw new InvalidLayoutException(String.format(
            "Reference layout ID %s does not match current layout ID %s.",
            update.getReferenceLayout(), currentLayout.getDesc().getLayoutId()));
      }

      final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(mKiji);
      validator.validate(
          currentLayout,
          KijiTableLayout.createUpdatedLayout(update , currentLayout));

      final TableLayoutTracker layoutTracker =
          new TableLayoutTracker(mZKClient, mTableURI, mLayoutUpdateHandler);
      try {
        layoutTracker.start();
        final UsersTracker usersTracker =
            ZooKeeperUtils
                .newTableUsersTracker(mZKClient, mTableURI)
                .registerUpdateHandler(mUsersUpdateHandler);
        try {
          usersTracker.start();
          final String currentLayoutId = mLayoutUpdateHandler.getCurrentLayoutId();
          LOG.info("Table {} has current layout ID {}.", mTableURI, currentLayoutId);
          if (!Objects.equal(currentLayoutId, currentLayout.getDesc().getLayoutId())) {
            throw new InternalKijiError(String.format(
                "Inconsistency between meta-table and ZooKeeper: "
                + "meta-table layout has ID %s while ZooKeeper has layout ID %s.",
                currentLayout.getDesc().getLayoutId(), currentLayoutId));
          }

          final String consistentLayoutId = waitForConsistentView();
          if ((consistentLayoutId != null) && !Objects.equal(consistentLayoutId, currentLayoutId)) {
            throw new InternalKijiError(String.format(
                "Consistent layout ID %s does not match current layout %s for table %s.",
                consistentLayoutId, currentLayout, mTableURI));
          }

          writeMetaTable(update);
          final TableLayoutDesc newLayoutDesc = mNewLayout.getDesc();
          writeZooKeeper(newLayoutDesc);

          mLayoutUpdateHandler.waitForLayoutNotification(newLayoutDesc.getLayoutId());

          // The following is not necessary:
          while (true) {
            final String newLayoutId = waitForConsistentView();
            if (newLayoutId == null) {
              LOG.info("Layout update complete for table {}: table has no users.", mTableURI);
              break;
            } else if (Objects.equal(newLayoutId, newLayoutDesc.getLayoutId())) {
              LOG.info("Layout update complete for table {}: all users switched to layout ID {}.",
                  mTableURI, newLayoutId);
              break;
            } else {
              LOG.info("Layout update in progress for table {}: users still using layout ID {}.",
                  mTableURI, newLayoutId);
              Time.sleep(1.0);
            }
          }

        } finally {
          usersTracker.close();
        }
      } finally {
        layoutTracker.close();
      }
    } finally {
      lock.unlock();
      lock.close();
    }
  }
View Full Code Here

Examples of org.neo4j.graphdb.Lock

   * @param initialValue the initial value of the given generator
   * @return the next value in a sequence
   */
  public int nextValue(IdSourceKey idSourceKey, int increment, int initialValue) {
    Transaction tx = neo4jDb.beginTx();
    Lock lock = null;
    try {
      Node sequence = getSequence( idSourceKey );

      if ( sequence == null ) {
        // sequence nodes are expected to have been created up-front
        if ( idSourceKey.getMetadata().getType() == IdSourceType.SEQUENCE ) {
          throw new HibernateException( "Sequence missing: " + idSourceKey.getMetadata().getName() );
        }
        // table sequence nodes (think of them as rows in a generator table) are created upon first usage
        else {
          addTableSequence( idSourceKey.getMetadata(), (String) idSourceKey.getColumnValues()[0], initialValue );
          sequence = getSequence( idSourceKey );
        }
      }

      lock = tx.acquireWriteLock( sequence );
      int nextValue = updateSequenceValue( idSourceKey, sequence, increment );
      tx.success();
      lock.release();
      return nextValue;
    }
    finally {
      tx.close();
    }
View Full Code Here

Examples of org.openbel.framework.common.lock.LockAdviser.Lock

    @Test
    public void testMultipleReadLocks() {
        final LockAdviser lockAdviser = LockAdviser.instance(lockDir);

        final Lock rlock1;
        final Lock rlock2;
        try {
            rlock1 = lockAdviser.obtainReadLock();
            rlock2 = lockAdviser.obtainReadLock();
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of org.openqa.selenium.firefox.internal.Lock

  }

  protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile,
                                          String host) {
    int profilePort = profile.getPort() == 0 ? DEFAULT_PORT : profile.getPort();
    Lock lock = new SocketLock(profilePort - 1);
    try {
      FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary;
     

      return new NewProfileExtensionConnection(lock, bin, profile, host);
    } catch (Exception e) {
      throw new WebDriverException(e);
    } finally {
      lock.unlock();
    }
  }
View Full Code Here

Examples of org.simoes.lpd.common.Lock

    /** constructor.
     * @param name - name of the print queue.
     */
    public PrintQueue(String name) {
    queue = new Queue(name);
    lock = new Lock(name);
    }
View Full Code Here

Examples of org.springframework.data.jpa.repository.Lock

          entityGraphAnnotation.type());
    }

    private static final LockModeType findLockModeType(Method method) {

      Lock annotation = AnnotationUtils.findAnnotation(method, Lock.class);
      return annotation == null ? null : (LockModeType) AnnotationUtils.getValue(annotation);
    }
View Full Code Here

Examples of org.zanata.lock.Lock

    @Override
    @Restrict("#{s:hasRole('admin')}")
    public Response updateTranslationMemory(String slug, InputStream input)
            throws Exception {
        Lock tmLock = lockTM(slug);
        try {
            Optional<TransMemory> tm = transMemoryDAO.getBySlug(slug);
            tmxParser.parseAndSaveTMX(input, getTM(tm, slug));
            return Response.ok().build();
        } finally {
View Full Code Here

Examples of railo.commons.lock.Lock

  @Override
  public LockData lock(int type, String name, int timeout, int pageContextId) throws LockTimeoutException, InterruptedException {
    if(!caseSensitive)name=name.toLowerCase();
    //if(type==LockManager.TYPE_READONLY) return new ReadLockData(name,pageContextId);
    if(timeout<=0)timeout=1;
    Lock lock;
    try {
      lock=locks.lock(name,timeout,type==LockManager.TYPE_READONLY);
    } catch (LockException e) {
      throw new LockTimeoutException(type,name,timeout);
    }
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.