Sends the current log directory to the remote node.

        Syncing will not occur if the cluster is not started
        with the Ray autoscaler.
174837
def sync_results_to_new_location(self, worker_ip):
        
        if worker_ip != self._log_syncer.worker_ip:
            self._log_syncer.set_worker_ip(worker_ip)
            self._log_syncer.sync_to_worker_if_possible()
804890
def _send(self):
        
        # Check to see if we have a valid socket. If not, try to connect.
        try:
            if self.influx is None:
                self.log.debug("InfluxdbHandler: Socket is not connected. "
                               "Reconnecting.")
                self._connect()
            if self.influx is None:
                self.log.debug("InfluxdbHandler: Reconnect failed.")
            else:
                # build metrics data
                metrics = []
                for path in self.batch:
                    metrics.append({
                        "points": self.batch[path],
                        "name": path,
                        "columns": ["time", "value"]})
                # Send data to influxdb
                self.log.debug("InfluxdbHandler: writing %d series of data",
                               len(metrics))
                self.influx.write_points(metrics,
                                         time_precision=self.time_precision)

                # empty batch buffer
                self.batch = {}
                self.batch_count = 0
                self.time_multiplier = 1

        except Exception:
            self._close()
            if self.time_multiplier < 5:
                self.time_multiplier += 1
            self._throttle_error(
                "InfluxdbHandler: Error sending metrics, waiting for %ds.",
                2**self.time_multiplier)
            raise
110050
function() {
        t.dirWatcher = FS.watch(t.dirPath, {persistent:false}, function(type){
          t.sync();
        });

        // Synchronize this object with the directory.
        t.sync(callback);
      }
320770
def send(self, local, remote, makedirs=False):
        '''
        
        '''
        if makedirs:
            self.exec_cmd('mkdir -p {0}'.format(os.path.dirname(remote)))

        # scp needs [<ipv6}
        host = self.host
        if ':' in host:
            host = '[{0}]'.format(host)

        cmd = '{0} {1}:{2}'.format(local, host, remote)
        cmd = self._cmd_str(cmd, ssh='scp')

        logmsg = 'Executing command: {0}'.format(cmd)
        if self.passwd:
            logmsg = logmsg.replace(self.passwd, ('*' * 6))
        log.debug(logmsg)

        return self._run_cmd(cmd)
1277848
public void setLog(String dataDirectory, boolean enablePurgeBySize, boolean enablePurgeByTime, long maxSize  , long minPurgeTime,
		String outOfSpaceAction, boolean enableBuffering, boolean fileSwitchEnabled, int fileSwitchTime){
		LogState state = ivLog.clone();
		state.ivDataDirectory = dataDirectory;
		state.ivPurgeBySizeEnabled = enablePurgeBySize ;
		state.ivPurgeByTimeEnabled = enablePurgeByTime ;
		state.ivPurgeMaxSize = maxSize;
		state.ivPurgeMinTime = minPurgeTime;
		state.ivOutOfSpaceAction = outOfSpaceAction;
		state.ivBufferingEnabled = enableBuffering ;
		state.ivFileSwitchEnabled = fileSwitchEnabled ;
		state.ivFileSwitchTime = fileSwitchTime ;

		updateLogConfiguration(state);
		
		state.copyTo(ivLog);
	}
53296
private void scanDirRecursively(final File dir, final LogNode log) {
        if (skipClasspathElement) {
            return;
        }
        // See if this canonical path has been scanned before, so that recursive scanning doesn't get stuck in an
        // infinite loop due to symlinks
        String canonicalPath;
        try {
            canonicalPath = dir.getCanonicalPath();
            if (!scannedCanonicalPaths.add(canonicalPath)) {
                if (log != null) {
                    log.log("Reached symlink cycle, stopping recursion: " + dir);
                }
                return;
            }
        } catch (final IOException | SecurityException e) {
            if (log != null) {
                log.log("Could not canonicalize path: " + dir, e);
            }
            return;
        }

        final String dirPath = dir.getPath();
        final String dirRelativePath = ignorePrefixLen > dirPath.length() ? "/" //
                : dirPath.substring(ignorePrefixLen).replace(File.separatorChar, '/') + "/";

        if (nestedClasspathRootPrefixes != null && nestedClasspathRootPrefixes.contains(dirRelativePath)) {
            if (log != null) {
                log.log("Reached nested classpath root, stopping recursion to avoid duplicate scanning: "
                        + dirRelativePath);
            }
            return;
        }

        // Whitelist/blacklist classpath elements based on dir resource paths
        checkResourcePathWhiteBlackList(dirRelativePath, log);
        if (skipClasspathElement) {
            return;
        }

        final ScanSpecPathMatch parentMatchStatus = scanSpec.dirWhitelistMatchStatus(dirRelativePath);
        if (parentMatchStatus == ScanSpecPathMatch.HAS_BLACKLISTED_PATH_PREFIX) {
            // Reached a non-whitelisted or blacklisted path -- stop the recursive scan
            if (log != null) {
                log.log("Reached blacklisted directory, stopping recursive scan: " + dirRelativePath);
            }
            return;
        }
        if (parentMatchStatus == ScanSpecPathMatch.NOT_WITHIN_WHITELISTED_PATH) {
            // Reached a non-whitelisted and non-blacklisted path -- stop the recursive scan
            return;
        }

        final File[] filesInDir = dir.listFiles();
        if (filesInDir == null) {
            if (log != null) {
                log.log("Invalid directory " + dir);
            }
            return;
        }
        Arrays.sort(filesInDir);
        final LogNode subLog = log == null ? null
                // Log dirs after files (addWhitelistedResources() precedes log entry with "0:")
                : log.log("1:" + canonicalPath, "Scanning directory: " + dir
                        + (dir.getPath().equals(canonicalPath) ? "" : " ; canonical path: " + canonicalPath));

        // Only scan files in directory if directory is not only an ancestor of a whitelisted path
        if (parentMatchStatus != ScanSpecPathMatch.ANCESTOR_OF_WHITELISTED_PATH) {
            // Do preorder traversal (files in dir, then subdirs), to reduce filesystem cache misses
            for (final File fileInDir : filesInDir) {
                // Process files in dir before recursing
                if (fileInDir.isFile()) {
                    final String fileInDirRelativePath = dirRelativePath.isEmpty() || "/".equals(dirRelativePath)
                            ? fileInDir.getName()
                            : dirRelativePath + fileInDir.getName();

                    // Whitelist/blacklist classpath elements based on file resource paths
                    checkResourcePathWhiteBlackList(fileInDirRelativePath, subLog);
                    if (skipClasspathElement) {
                        return;
                    }

                    // If relative path is whitelisted
                    if (parentMatchStatus == ScanSpecPathMatch.HAS_WHITELISTED_PATH_PREFIX
                            || parentMatchStatus == ScanSpecPathMatch.AT_WHITELISTED_PATH
                            || (parentMatchStatus == ScanSpecPathMatch.AT_WHITELISTED_CLASS_PACKAGE
                                    && scanSpec.classfileIsSpecificallyWhitelisted(fileInDirRelativePath))) {
                        // Resource is whitelisted
                        final Resource resource = newResource(fileInDirRelativePath, fileInDir);
                        addWhitelistedResource(resource, parentMatchStatus, subLog);

                        // Save last modified time  
                        fileToLastModified.put(fileInDir, fileInDir.lastModified());
                    } else {
                        if (subLog != null) {
                            subLog.log("Skipping non-whitelisted file: " + fileInDirRelativePath);
                        }
                    }
                }
            }
        } else if (scanSpec.enableClassInfo && dirRelativePath.equals("/")) {
            // Always check for module descriptor in package root, even if package root isn't in whitelist
            for (final File fileInDir : filesInDir) {
                if (fileInDir.getName().equals("module-info.class") && fileInDir.isFile()) {
                    final Resource resource = newResource("module-info.class", fileInDir);
                    addWhitelistedResource(resource, parentMatchStatus, subLog);
                    fileToLastModified.put(fileInDir, fileInDir.lastModified());
                }
            }
        }
        // Recurse into subdirectories
        for (final File fileInDir : filesInDir) {
            if (fileInDir.isDirectory()) {
                scanDirRecursively(fileInDir, subLog);
                // If a blacklisted classpath element resource path was found, it will set skipClasspathElement
                if (skipClasspathElement) {
                    if (subLog != null) {
                        subLog.addElapsedTime();
                    }
                    return;
                }
            }
        }

        if (subLog != null) {
            subLog.addElapsedTime();
        }

        // Save the last modified time of the directory
        fileToLastModified.put(dir, dir.lastModified());
    }
676731
void startFile(String src, PermissionStatus permissions,
                 String holder, String clientMachine,
                 boolean overwrite, boolean createParent, short replication, long blockSize
  ) throws IOException {
    INodeFileUnderConstruction file =
      startFileInternal(src, permissions, holder, clientMachine, overwrite, false,
      createParent, replication, blockSize);
    getEditLog().logSync(false);
    if (auditLog.isInfoEnabled()) {
      logAuditEvent(getCurrentUGI(),
        Server.getRemoteIp(),
        "create", src, null, file);
    }
  }
1175464
def send_cluster_time(self, command, session, client):
        """"""
        if self.max_wire_version >= 6 and client:
            client._send_cluster_time(command, session)
1007265
private void transferLogFilesToS3() {
        if (_fileTransfersEnabled) {
            // Find all closed log files in the staging directory and move them to S3
            for (final File logFile : _stagingDir.listFiles((dir, name) -> name.startsWith(_logFilePrefix) && name.endsWith(COMPRESSED_FILE_SUFFIX))) {
                // Extract the date portion of the file name and is it to partition the file in S3
                String auditDate = logFile.getName().substring(_logFilePrefix.length() + 1, _logFilePrefix.length() + 9);
                String dest = String.format("%s/date=%s/%s", _s3AuditRoot, auditDate, logFile.getName());

                _fileTransferService.submit(() -> {
                    // Since file transfers are done in a single thread, there shouldn't be any concurrency issues,
                    // but verify the same file wasn't submitted previously and is already transferred.
                    if (logFile.exists()) {
                        try {
                            PutObjectResult result = _s3.putObject(_s3Bucket, dest, logFile);
                            _log.debug("Audit log copied: {}, ETag={}", logFile, result.getETag());

                            if (!logFile.delete()) {
                                _log.warn("Failed to delete file after copying to s3: {}", logFile);
                            }
                        } catch (Exception e) {

                            // Log the error, try again on the next iteration
                            _rateLimitedLog.error(e, "Failed to copy log file {}", logFile);
                        }
                    }
                });
            }
        }

    }
1167841
def send_file(self, local_path, remote_path, user='root', unix_mode=None):
        
        self.enable_user(user)
        return self.ssh_pool.send_file(user, local_path, remote_path, unix_mode=unix_mode)
416284
public synchronized void saveWorkdir() throws IOException {
    Preconditions.checkState(mState == State.STARTED,
        "cluster must be started before you can save its work directory");
    ARTIFACTS_DIR.mkdirs();

    File tarball = new File(mWorkDir.getParentFile(), mWorkDir.getName() + ".tar.gz");
    // Tar up the work directory.
    ProcessBuilder pb =
        new ProcessBuilder("tar", "-czf", tarball.getName(), mWorkDir.getName());
    pb.directory(mWorkDir.getParentFile());
    pb.redirectOutput(Redirect.appendTo(TESTS_LOG));
    pb.redirectError(Redirect.appendTo(TESTS_LOG));
    Process p = pb.start();
    try {
      p.waitFor();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(e);
    }
    // Move tarball to artifacts directory.
    File finalTarball = new File(ARTIFACTS_DIR, tarball.getName());
    FileUtils.moveFile(tarball, finalTarball);
    LOG.info("Saved cluster {} to {}", mClusterName, finalTarball.getAbsolutePath());
  }
1203091
private void sendDirectory(final YokeRequest request, final String dir, final Handler<Object> next) {
        final FileSystem fileSystem = vertx().fileSystem();

        fileSystem.readDir(dir, new AsyncResultHandler<List<String>>() {
            @Override
            public void handle(AsyncResult<List<String>> asyncResult) {
                if (asyncResult.failed()) {
                    next.handle(asyncResult.cause());
                } else {
                    String accept = request.getHeader("accept", "text/plain");

                    if (accept.contains("html")) {
                        String normalizedDir = dir.substring(root.length());
                        if (!normalizedDir.endsWith("/")) {
                            normalizedDir += "/";
                        }

                        String file;
                        StringBuilder files = new StringBuilder("<ul id=\"files\">");

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            files.append("<li><a href=\"");
                            files.append(normalizedDir);
                            files.append(file);
                            files.append("\" title=\"");
                            files.append(file);
                            files.append("\">");
                            files.append(file);
                            files.append("</a></li>");
                        }

                        files.append("</ul>");

                        StringBuilder directory = new StringBuilder();
                        // define access to root
                        directory.append("<a href=\"/\">/</a> ");

                        StringBuilder expandingPath = new StringBuilder();
                        String[] dirParts = normalizedDir.split("/");
                        for (int i = 1; i < dirParts.length; i++) {
                            // dynamic expansion
                            expandingPath.append("/");
                            expandingPath.append(dirParts[i]);
                            // anchor building
                            if (i > 1) {
                                directory.append(" / ");
                            }
                            directory.append("<a href=\"");
                            directory.append(expandingPath.toString());
                            directory.append("\">");
                            directory.append(dirParts[i]);
                            directory.append("</a>");
                        }

                        request.response().setContentType("text/html");
                        request.response().end(
                                directoryTemplate.replace("{title}", (String) request.get("title")).replace("{directory}", normalizedDir)
                                        .replace("{linked-path}", directory.toString())
                                        .replace("{files}", files.toString()));
                    } else if (accept.contains("json")) {
                        String file;
                        JsonArray json = new JsonArray();

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            json.add(file);
                        }

                        request.response().end(json);
                    } else {
                        String file;
                        StringBuilder buffer = new StringBuilder();

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            buffer.append(file);
                            buffer.append('\n');
                        }

                        request.response().setContentType("text/plain");
                        request.response().end(buffer.toString());
                    }
                }
            }
        });
    }
697696
public synchronized void writeLog(String log) throws IOException {
		if (mFile.length() < mFileMaxSize) {
			writeLogToFile(log, mFile, true);
		} else {
			rotateLogFiles();
			createNewFile();
			writeLogToFile(log, mFile, false);
		}
	}
1172366
void send(final RunningTask reefTask, final MasterToWorkerRequest masterToWorkerRequest) {
    reefTask.send(kryoUtils.serialize(masterToWorkerRequest));
  }
805497
def cli(env, volume_id, replicant_id, immediate):
    """"""
    block_storage_manager = SoftLayer.BlockStorageManager(env.client)

    success = block_storage_manager.failover_to_replicant(
        volume_id,
        replicant_id,
        immediate
    )

    if success:
        click.echo("Failover to replicant is now in progress.")
    else:
        click.echo("Failover operation could not be initiated.")
932503
private boolean nodesChanged() throws ClusterInfoException {
        if (!imIt) {
            LOGGER.warn("Was notified of a nodes change but I'm not the master.");
            return true;
        } else
            LOGGER.trace("Master was notifed of node changes");

        // current nodes registered, sorted by rank
        final List<SubdirAndData<C>> currentNodes = chain(
                // I need to be notified when Nodes appear or disappear v
                utils.persistentGetSubdirAndData(utils.nodesDir, nodesChangedTask, null), p -> Utils.rankSort(p));

        // get all of the current shard assignments
        @SuppressWarnings("unchecked")
        final List<ShardAssignment<C>> assignments = Optional
                .ofNullable((List<ShardAssignment<C>>) utils.persistentGetData(utils.shardsAssignedDir, null))
                .orElse(new ArrayList<>());

        // Build a lookup to determine the rank of a given node denoted by its ContainerAddress
        final Map<C, Integer> rankByCa = new HashMap<>();
        for (int i = 0; i < currentNodes.size(); i++)
            rankByCa.put(currentNodes.get(i).data, Integer.valueOf(i));

        // create an array of already assigned and accepted addresses
        final C[] assignedTo = newArraySupplier.apply(totalNumShards);
        for (final ShardAssignment<C> sa : assignments) {
            // do we know about this destination?
            if (rankByCa.get(sa.addr) != null) {
                for (final int shard : sa.shards) {
                    if (assignedTo[shard] == null)
                        assignedTo[shard] = sa.addr;
                    else
                        // the shard is assigned twice.
                        LOGGER.warn("Shard " + shard + " is assigned to 2 nodes. " + assignedTo[shard] + " and " + sa.addr);
                }
            } else {
                LOGGER.info("The node " + sa.addr + " seems to have dissapeared.");
            }
        }

        // for each node in order I need to build a reduced state.
        for (int i = currentNodes.size() - 1; i >= 0; i--) {
            final C cur = currentNodes.get(i).data;

            final Set<Integer> shardsToRelease = perNodeRelease(cur, assignedTo, currentNodes.size(), i);
            for (final Integer shard : shardsToRelease) {
                assignedTo[shard] = null;
            }
        }

        // now go through and add
        for (int i = 0; i < currentNodes.size(); i++) {
            final C cur = currentNodes.get(i).data;
            final Set<Integer> shardsToAdd = perNodeAcquire(cur, assignedTo, currentNodes.size(), i);
            for (final Integer shard : shardsToAdd) {
                assignedTo[shard] = cur;
            }
        }

        // now write the results.
        final Map<C, List<Integer>> tmp = new HashMap<>();
        for (int i = 0; i < assignedTo.length; i++) {
            final C cur = assignedTo[i];
            if (cur != null) {
                List<Integer> shards = tmp.get(cur);
                if (shards == null) {
                    shards = new ArrayList<>();
                    tmp.put(cur, shards);
                }
                shards.add(Integer.valueOf(i));
            }
        }

        // now create the list of new assignments.
        final List<ShardAssignment<C>> newAssignments = new ArrayList<>(tmp.entrySet().stream()
                .map(e -> new ShardAssignment<C>(e.getValue().stream().mapToInt(i -> i.intValue()).toArray(), e.getKey(), totalNumShards, minNodes))
                .collect(Collectors.toList()));

        session.setData(utils.shardsAssignedDir, newAssignments);
        return true;
    }
927295
public void setLogFileDir(String logDirName) {
        File logDir = new File(logDirName);
        if (!logDir.isAbsolute()) {
            logDir = new File(serverBaseDir, logDirName);
        }

        this.logFileDir = logDirName;
        if (started) {
            configuration.setLogFileDir(logDir.getAbsolutePath());
        }
    }