/** * 获取指定名称的队列存储实例 如果不存存在,根据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; }
@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); }
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); } }
private AbstractQueue<RemoteFile> getRemoteFileList(String folder) { AbstractQueue<RemoteFile> list = new ConcurrentLinkedQueue<>(); try { getRemoteFileListAux(folder, list); } catch (IOException ex) { ex.printStackTrace(); } return list; }
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); } } }
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); } } }
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); } }
/** * {@inheritDoc} */ @Override protected AbstractQueue<T> newCollection() { return new PriorityQueue<T>(); }
Collector(AbstractQueue<FIFOEntry<Revision>> outgoingQueue, RevisionProcessor nextProcessor, int runningWorkerThreads) { this.outgoingQueue = outgoingQueue; this.nextProcessor = nextProcessor; this.runningWorkerThreads = runningWorkerThreads; }
public QueueTest(AbstractQueue<Integer> queue) { this.queue = queue; }
@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); }
public ResumeBackupCommand(AbstractQueue<BackupItem> queue, String backupDir, Activity act) { this.queue = queue; this.act = act; this.backupDir = backupDir; }
public ResumeRestoreCommand(AbstractQueue<RemoteFile> queue, String targetPath, Activity act) { this.queue = queue; this.targetPath = targetPath; this.act = act; }
public EventQueueWorker(AbstractQueue<Event> queue) { this.queue = queue; }
/** {@inheritDoc} */ @Override protected AbstractQueue<T> newCollection() { return new PriorityQueue<T>(); }
/** * 获取或者创建指定名称的队列存储实例 * * @param name * @return * @throws Exception */ private AbstractQueue<byte[]> getClientQueue(String name) throws Exception { return getClientQueue(name, true); }