Examples of CCDB2Instance


Examples of com.shop.util.ccdb2.CCDB2Instance

    {
      try
      {
        int        dotIndex = f.getName().indexOf('.');
        String       unextendedName = (dotIndex > 0) ? f.getName().substring(0, dotIndex) : f.getName();
        CCDB2Instance   instance = new CCDB2Instance(this, f.getParentFile(), unextendedName, fParameters.getBackgroundPutLength());
        if ( (System.currentTimeMillis() - instance.getCreationTime()) < (fParameters.getMaxAgeMilliseconds() * 2) )
        {
          localList.add(instance);
        }
        else
        {
          instance.delete();
        }
      }
      catch ( CCDB2Instance.OldFileException e )
      {
        System.out.println(e.getMessage());
      }
      catch ( IOException e )
      {
        log("", e, true);
      }
    }

    Collections.sort
    (
      localList,
      new Comparator<CCDB2Instance>()
      {
        @Override
        public int compare(CCDB2Instance o1, CCDB2Instance o2)
        {
          long diff = o1.getCreationTime() - o2.getCreationTime();
          return (diff < 0) ? -1 : ((diff > 0) ? 1 : 0);
        }
      }
    );

    if ( localList.size() == 0 )
    {
      CCDB2Instance     newInstance = makeNewInstance();
      localList.add(newInstance);
    }

    while ( localList.size() > fParameters.getMaxInstances() )
    {
      CCDB2Instance    instance = localList.remove(0);
      instance.delete();
    }

    CCDB2InstanceLoader loader = new CCDB2InstanceLoader
    (
      this,
      localList,
      new CCDB2InstanceLoader.ProcessDriver()
      {
        @Override
        public void process(CCDB2Instance instance, AtomicInteger percentDone) throws IOException
        {
          instance.loadFile(percentDone);
        }
      }
    );
    log("Loading...", null, true);
    loader.load();
View Full Code Here

Examples of com.shop.util.ccdb2.CCDB2Instance

      AtomicReference<Boolean>     wasDeleted = new AtomicReference<Boolean>(false);
      ListIterator<CCDB2Instance> iterator = reverseIterator();
      ccdb2Spec = null;
      while ( (ccdb2Spec == null) && iterator.hasPrevious() )
      {
        CCDB2Instance instance = iterator.previous();
        if ( wasDeleted.get() )
        {
          instance.removeFromIndex(key);
        }
        else
        {
          ccdb2Spec = instance.get(key, wasDeleted);
        }
      }
    }
    finally
    {
View Full Code Here

Examples of com.shop.util.ccdb2.CCDB2Instance

    {
      boolean             isFirst = true;
      ListIterator<CCDB2Instance>   iterator = reverseIterator();
      while ( iterator.hasPrevious() )
      {
        CCDB2Instance    instance = iterator.previous();
        try
        {
          if ( isFirst )
          {
            isFirst = false;
            instance.put(key, ccdb2Spec, ccdb2Groups);
          }
          else
          {
            instance.removeFromIndex(key);
          }
        }
        catch ( CCDB2SetFileLengthException e )
        {
          fDriver.setErrorState("Out of Disk Space");
View Full Code Here

Examples of com.shop.util.ccdb2.CCDB2Instance

    {
      boolean             isFirst = true;
      ListIterator<CCDB2Instance>   iterator = reverseIterator();
      while ( iterator.hasPrevious() )
      {
        CCDB2Instance   instance = iterator.previous();
        if ( isFirst )
        {
          isFirst = false;
          instance.remove(key);
        }
        else
        {
          instance.removeFromIndex(key);
        }
      }
    }
    finally
    {
View Full Code Here

Examples of com.shop.util.ccdb2.CCDB2Instance

  {
    /**
     * allocate a new instance just in case it's needed - that way it
     * won't be done while synchronized
     */
    CCDB2Instance   newInstance;
    try
    {
      newInstance = makeNewInstance();
    }
    catch ( IOException e )
    {
      handleException(e);
      return;
    }

    CCDB2Instance     deleteInstance = null;

    fLock.writeLock().lock();
    try
    {
      if ( fInstances.size() > 0 )
      {
        CCDB2Instance     mainInstance = fInstances.get(fInstances.size() - 1);
        if ( (System.currentTimeMillis() - mainInstance.getCreationTime()) >= fParameters.getShuffleMilliseconds() )
        {
          if ( fInstances.size() >= fParameters.getMaxInstances() )
          {
            deleteInstance = fInstances.remove(0);
          }
View Full Code Here

Examples of com.shop.util.ccdb2.CCDB2Instance

  }

  private CCDB2Instance makeNewInstance() throws IOException
  {
    String      filename = fParameters.getFilePrefix() + System.nanoTime();
    return new CCDB2Instance(this, fDirectoryPath, filename, fParameters.getBackgroundPutLength());
  }
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.