private void filesChangedWorker() { // TODO: once this is editable, make sure changes are committed fileDetails.reset(); for (final FileObject file : table.getSelectedFiles()) fileDetails.showFileDetails(file); if (fileDetails.getDocument().getLength() > 0 && table.areAllSelectedFilesUploadable()) fileDetails.setEditableForDevelopers(); for (final FileAction button : fileActions) button.enableIfValid(); apply.setEnabled(files.hasChanges()); cancel.setText(files.hasChanges() ? "Cancel" : "Close"); if (files.hasUploadableSites()) enableUploadOrNot(); int install = 0, uninstall = 0, upload = 0; long bytesToDownload = 0, bytesToUpload = 0; for (final FileObject file : files) switch (file.getAction()) { case INSTALL: case UPDATE: install++; bytesToDownload += file.filesize; break; case UNINSTALL: uninstall++; break; case UPLOAD: upload++; bytesToUpload += file.filesize; break; } int implicated = 0; final DependencyMap map = files.getDependencies(true); for (final FileObject file : map.keySet()) { implicated++; bytesToUpload += file.filesize; } String text = ""; if (install > 0) text += " install/update: " + install + (implicated > 0 ? "+" + implicated : "") + " (" + sizeToString(bytesToDownload) + ")"; if (uninstall > 0) text += " uninstall: " + uninstall; if (files.hasUploadableSites() && upload > 0) text += " upload: " + upload + " (" + sizeToString(bytesToUpload) + ")"; fileSummary.setText(text); }
/** * Extracts some details about the files to compact that are commonly needed by compactors. * * @param filesToCompact Files. * @param allFiles Whether all files are included for compaction * @return The result. */ protected FileDetails getFileDetails(Collection<StoreFile> filesToCompact, boolean allFiles) throws IOException { FileDetails fd = new FileDetails(); long oldestHFileTimeStampToKeepMVCC = System.currentTimeMillis() - (1000L * 60 * 60 * 24 * this.keepSeqIdPeriod); for (StoreFile file : filesToCompact) { if (allFiles && (file.getModificationTimeStamp() < oldestHFileTimeStampToKeepMVCC)) { // when isAllFiles is true, all files are compacted so we can calculate the smallest // MVCC value to keep if (fd.minSeqIdToKeep < file.getMaxMemstoreTS()) { fd.minSeqIdToKeep = file.getMaxMemstoreTS(); } } long seqNum = file.getMaxSequenceId(); fd.maxSeqId = Math.max(fd.maxSeqId, seqNum); StoreFile.Reader r = file.getReader(); if (r == null) { LOG.warn("Null reader for " + file.getPath()); continue; } // NOTE: getFilterEntries could cause under-sized blooms if the user // switches bloom type (e.g. from ROW to ROWCOL) long keyCount = (r.getBloomFilterType() == store.getFamily().getBloomFilterType()) ? r.getFilterEntries() : r.getEntries(); fd.maxKeyCount += keyCount; // calculate the latest MVCC readpoint in any of the involved store files Map<byte[], byte[]> fileInfo = r.loadFileInfo(); byte tmp[] = fileInfo.get(HFileWriterV2.MAX_MEMSTORE_TS_KEY); if (tmp != null) { fd.maxMVCCReadpoint = Math.max(fd.maxMVCCReadpoint, Bytes.toLong(tmp)); } tmp = fileInfo.get(FileInfo.MAX_TAGS_LEN); if (tmp != null) { fd.maxTagsLength = Math.max(fd.maxTagsLength, Bytes.toInt(tmp)); } // If required, calculate the earliest put timestamp of all involved storefiles. // This is used to remove family delete marker during compaction. long earliestPutTs = 0; if (allFiles) { tmp = fileInfo.get(StoreFile.EARLIEST_PUT_TS); if (tmp == null) { // There's a file with no information, must be an old one // assume we have very old puts fd.earliestPutTs = earliestPutTs = HConstants.OLDEST_TIMESTAMP; } else { earliestPutTs = Bytes.toLong(tmp); fd.earliestPutTs = Math.min(fd.earliestPutTs, earliestPutTs); } } if (LOG.isDebugEnabled()) { LOG.debug( "Compacting " + file + ", keycount=" + keyCount + ", bloomtype=" + r.getBloomFilterType().toString() + ", size=" + StringUtils.humanReadableInt(r.length()) + ", encoding=" + r.getHFileReader().getDataBlockEncoding() + ", seqNum=" + seqNum + (allFiles ? ", earliestPutTs=" + earliestPutTs : "")); } } return fd; }
/** * Process all the requests. The connection must have been opened and set first. * * @param requests the requets to process */ public void processRequests(List requests) throws IOException, UnconfiguredRequestException, ResponseException, CommandAbortedException { if (requests == null || requests.size() == 0) { throw new IllegalArgumentException( "[processRequests] requests " + // NOI18N "was either null or empty."); // NOI18N } if (abort) { throw new CommandAbortedException( "Aborted during request processing", // NOI18N CommandException.getLocalMessage("Client.commandAborted", null)); // NOI18N } loggedDataInputStream = null; loggedDataOutputStream = null; // send the initialisation requests if we are handling the first // command boolean filterRootRequest = true; if (isFirstCommand()) { setIsFirstCommand(false); int pos = 0; if (!initialRequestsSent) { pos = fillInitialRequests(requests); initialRequestsSent = true; filterRootRequest = false; } if (globalOptions != null) { // sends the global options that are to be sent to server (-q, -Q, -t, -n, l) for (Iterator it = globalOptions.createRequestList().iterator(); it.hasNext(); ) { Request request = (Request) it.next(); requests.add(pos++, request); } if (globalOptions.isUseGzip() && globalOptions.getCompressionLevel() != 0) { requests.add(pos++, new GzipFileContentsRequest(globalOptions.getCompressionLevel())); } } } else if (printConnectionReuseWarning) { if (System.getProperty("javacvs.multiple_commands_warning") == null) { // NOI18N System.err.println("WARNING TO DEVELOPERS:"); // NOI18N System.err.println( "Please be warned that attempting to reuse one open connection for more commands is not supported by cvs servers very well."); // NOI18N System.err.println("You are advised to open a new Connection each time."); // NOI18N System.err.println( "If you still want to proceed, please do: System.setProperty(\"javacvs.multiple_commands_warning\", \"false\")"); // NOI18N System.err.println("That will disable this message."); // NOI18N } } if (!ALLOWED_CONNECTION_REUSE_REQUESTS.contains(requests.get(requests.size() - 1).getClass())) { printConnectionReuseWarning = true; } final boolean fireEnhancedEvents = getEventManager().isFireEnhancedEventSet(); int fileDetailRequestCount = 0; if (fireEnhancedEvents) { for (Iterator it = requests.iterator(); it.hasNext(); ) { Request request = (Request) it.next(); FileDetails fileDetails = request.getFileForTransmission(); if (fileDetails != null && fileDetails.getFile().exists()) { fileDetailRequestCount++; } } CVSEvent event = new EnhancedMessageEvent( this, EnhancedMessageEvent.REQUESTS_COUNT, new Integer(fileDetailRequestCount)); getEventManager().fireCVSEvent(event); } LoggedDataOutputStream dos = connection.getOutputStream(); loggedDataOutputStream = dos; // this list stores stream modification requests, each to be called // to modify the input stream the next time we need to process a // response List streamModifierRequests = new LinkedList(); // sending files does not seem to allow compression transmitFileHandler = getUncompressedFileHandler(); for (Iterator it = requests.iterator(); it.hasNext(); ) { if (abort) { throw new CommandAbortedException( "Aborted during request processing", // NOI18N CommandException.getLocalMessage("Client.commandAborted", null)); // NOI18N } final Request request = (Request) it.next(); if (request instanceof GzipFileContentsRequest) { if (dontUseGzipFileHandler) { stderr.println( "Warning: The server is not supporting gzip-file-contents request, no compression is used."); continue; } } // skip the root request if already sent if (request instanceof RootRequest) { if (filterRootRequest) { continue; } else { // Even if we should not filter the RootRequest now, we must filter all successive // RootRequests filterRootRequest = true; } } // send request to server String requestString = request.getRequestString(); dos.writeBytes(requestString); // we must modify the outputstream now, but defer modification // of the inputstream until we are about to read a response. // This is because some modifiers (e.g. gzip) read the header // on construction, and obviously no header is present when // no response has been sent request.modifyOutputStream(connection); if (request.modifiesInputStream()) { streamModifierRequests.add(request); } dos = connection.getOutputStream(); FileDetails fileDetails = request.getFileForTransmission(); if (fileDetails != null) { final File file = fileDetails.getFile(); // only transmit the file if it exists! When committing // a remove request you cannot transmit the file if (file.exists()) { Logger.logOutput( new String( "<Sending file: " + // NOI18N file.getAbsolutePath() + ">\n") .getBytes("utf8")); // NOI18N if (fireEnhancedEvents) { CVSEvent event = new EnhancedMessageEvent(this, EnhancedMessageEvent.FILE_SENDING, file); getEventManager().fireCVSEvent(event); fileDetailRequestCount--; } if (fileDetails.isBinary()) { transmitFileHandler.transmitBinaryFile(file, dos); } else { transmitFileHandler.transmitTextFile(file, dos); } if (fireEnhancedEvents && fileDetailRequestCount == 0) { CVSEvent event = new EnhancedMessageEvent(this, EnhancedMessageEvent.REQUESTS_SENT, "Ok"); // NOI18N getEventManager().fireCVSEvent(event); } } } if (request.isResponseExpected()) { dos.flush(); // now perform the deferred modification of the input stream Iterator modifiers = streamModifierRequests.iterator(); while (modifiers.hasNext()) { System.err.println("Modifying the inputstream..."); // NOI18N final Request smRequest = (Request) modifiers.next(); System.err.println( "Request is a: " + // NOI18N smRequest.getClass().getName()); smRequest.modifyInputStream(connection); } streamModifierRequests.clear(); handleResponse(); } } dos.flush(); transmitFileHandler = null; }