Java Code Examples for java.util.AbstractQueue

The following are top voted examples for showing how to use java.util.AbstractQueue. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: fqueue   File: FSStorage.java   View source code 6 votes vote down vote up
/**
 * 获取指定名称的队列存储实例 如果不存存在,根据create参数决定是否创建
 * 
 * @param name
 * @return
 * @throws Exception
 */
private AbstractQueue<byte[]> getClientQueue(String name, boolean create) throws Exception {
    AbstractQueue<byte[]> queue = queuemMap.get(name);
    if (queue == null) {
        if (create == true) {
            lock.lock();
            try {
                queue = queuemMap.get(name);
                if (queue == null) {
                    queue = new FQueue(dbpath + "/" + name, logSize);
                    queuemMap.put(name, queue);
                }
            } finally {
                lock.unlock();
            }
        }
    }
    return queue;
}
 
Example 2
Project: caboclo   File: ControlBackup.java   View source code 5 votes vote down vote up
@Override
public void doBackup(ArrayList<String> target, Activity act) {

    //Hash map that links each File to its related root folder
    AbstractQueue<BackupItem> queue = new ConcurrentLinkedQueue<BackupItem>();
    
    //Create list of objects to
    for (int i = 0; i < target.size(); i++) {
        String rootFolder = target.get(i);
        getLocalFileList(queue, rootFolder);
    }        

    String backupName = getBackupId();

    try {
        client.makedir("/backups/" + backupName);
    } catch (IOException ex) {
        Logger.getLogger(ControlBackup.class.getName()).log(Level.SEVERE, null, ex);
        act.cancel();
        return;
    }

    String backupDir = "/backups/" + backupName;

    Command comm = new ResumeBackupCommand(queue, backupDir, act);
    act.setResumeCommand(comm);

    resumeBackup(queue, backupDir, act);
}
 
Example 3
Project: caboclo   File: ControlBackup.java   View source code 5 votes vote down vote up
private void getLocalFileList(AbstractQueue<BackupItem> list, String rootFolder) {
    File dir = new java.io.File(rootFolder);
    list.add(new BackupItem(dir, rootFolder));

    if (dir.isDirectory()) {
        getLocalFileListAux(dir, list, rootFolder);
    }        
}
 
Example 4
Project: caboclo   File: ControlBackup.java   View source code 5 votes vote down vote up
private AbstractQueue<RemoteFile> getRemoteFileList(String folder) {
    AbstractQueue<RemoteFile> list = new ConcurrentLinkedQueue<>();

    try {
        getRemoteFileListAux(folder, list);
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    return list;
}
 
Example 5
Project: caboclo   File: ControlBackup.java   View source code 5 votes vote down vote up
private void getLocalFileListAux(java.io.File dir, AbstractQueue<BackupItem> list, String rootFolder) {

        for (java.io.File child : dir.listFiles()) {

            list.add(new BackupItem(child, rootFolder));

            if (child.isDirectory()) {
                getLocalFileListAux(child, list, rootFolder);
            }
        }
    }
 
Example 6
Project: caboclo   File: ControlBackup.java   View source code 5 votes vote down vote up
private void getRemoteFileListAux(String folder, AbstractQueue<RemoteFile> list) throws IOException {

        for (RemoteFile child : client.getChildren(folder)) {
            list.add(child);

            if (child.isDirectory()) {
                getRemoteFileListAux(child.getPath(), list);
            }
        }
    }
 
Example 7
Project: yuzhouwan   File: GCTest.java   View source code 5 votes vote down vote up
public void run() {
    AbstractQueue<String> q = new ArrayBlockingQueue<>(GCTest.countDownSize);
    char[] srcArray;
    String emptyStr;
    long finishedUnit = 0;
    long prevTime = timeZero;

    for (int i = 0; ; i = i + 1) {
        // Simulate object use to force promotion into OldGen and then GC
        if (q.size() >= GCTest.countDownSize) {
            for (int j = 0; j < GCTest.eachRemoveSize; j++) {
                q.remove();
            }
            finishedUnit++;

            // every 1000 removal is counted as 1 unit.
            long curTime = System.currentTimeMillis();
            long totalTime = curTime - timeZero;
            if (totalTime > GCTest.duration * 1000) {
                System.exit(0);
            }
            Date dNow = new Date();
            SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
            System.out.println(ft.format(dNow) + " finished Units (1K) = " + finishedUnit);
        }
        srcArray = new char[GCTest.referenceSize];
        emptyStr = new String(srcArray);
        String str = emptyStr.replace('\0', 'a');
        q.add(str);
    }
}
 
Example 8
Project: gwt-jackson-apt   File: AbstractQueueJsonDeserializer.java   View source code 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected AbstractQueue<T> newCollection() {
    return new PriorityQueue<T>();
}
 
Example 9
Project: cikm16-wdvd-feature-extraction   File: ParallelProcessor.java   View source code 4 votes vote down vote up
Collector(AbstractQueue<FIFOEntry<Revision>> outgoingQueue,
		RevisionProcessor nextProcessor, int runningWorkerThreads) {
	this.outgoingQueue = outgoingQueue;
	this.nextProcessor = nextProcessor;
	this.runningWorkerThreads = runningWorkerThreads;
}
 
Example 10
Project: NonDex   File: QueueTest.java   View source code 4 votes vote down vote up
public QueueTest(AbstractQueue<Integer> queue) {
    this.queue = queue;
}
 
Example 11
Project: NonDex   File: QueueTest.java   View source code 4 votes vote down vote up
public QueueTest(AbstractQueue<Integer> queue) {
    this.queue = queue;
}
 
Example 12
Project: caboclo   File: ControlBackup.java   View source code 4 votes vote down vote up
@Override
public void doRestore(String folder, String targetPath, Activity act) {
    String rootFolder = folder.startsWith("/backups/") ? folder : ("/backups/" + folder);

    act.storeObject("rootFolder", rootFolder);

    //TODO - Potentially long operation, todo: if the user abort it, then start all over again due to the recursive method
    
    AbstractQueue<RemoteFile> queue = getRemoteFileList(rootFolder);

    Command comm = new ResumeRestoreCommand(queue, targetPath, act);
    act.setResumeCommand(comm);

    act.saveActivity();

    resumeRestore(queue, targetPath, act);
}
 
Example 13
Project: caboclo   File: ControlBackup.java   View source code 4 votes vote down vote up
public ResumeBackupCommand(AbstractQueue<BackupItem> queue,
        String backupDir, Activity act) {
    this.queue = queue;
    this.act = act;
    this.backupDir = backupDir;
}
 
Example 14
Project: caboclo   File: ControlBackup.java   View source code 4 votes vote down vote up
public ResumeRestoreCommand(AbstractQueue<RemoteFile> queue, String targetPath, Activity act) {
    this.queue = queue;
    this.targetPath = targetPath;
    this.act = act;
}
 
Example 15
Project: jes   File: EventQueueWorker.java   View source code 4 votes vote down vote up
public EventQueueWorker(AbstractQueue<Event> queue) {
    this.queue = queue;
}
 
Example 16
Project: gwt-jackson   File: AbstractQueueJsonDeserializer.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected AbstractQueue<T> newCollection() {
    return new PriorityQueue<T>();
}
 
Example 17
Project: fqueue   File: FSStorage.java   View source code 2 votes vote down vote up
/**
 * 获取或者创建指定名称的队列存储实例
 * 
 * @param name
 * @return
 * @throws Exception
 */
private AbstractQueue<byte[]> getClientQueue(String name) throws Exception {
    return getClientQueue(name, true);
}