Search in sources :

Example 96 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.

the class FSQueueMetrics method forQueue.

/**
   * Get the FS queue metric for the given queue. Create one and register it to
   * metrics system if there isn't one for the queue.
   *
   * @param ms the metric system
   * @param queueName queue name
   * @param parent parent queue
   * @param enableUserMetrics  if user metrics is needed
   * @param conf configuration
   * @return an FSQueueMetrics object
   */
@VisibleForTesting
public static synchronized FSQueueMetrics forQueue(MetricsSystem ms, String queueName, Queue parent, boolean enableUserMetrics, Configuration conf) {
    QueueMetrics metrics = queueMetrics.get(queueName);
    if (metrics == null) {
        metrics = new FSQueueMetrics(ms, queueName, parent, enableUserMetrics, conf).tag(QUEUE_INFO, queueName);
        // Register with the MetricsSystems
        if (ms != null) {
            metrics = ms.register(sourceName(queueName).toString(), "Metrics for queue: " + queueName, metrics);
        }
        queueMetrics.put(queueName, metrics);
    }
    return (FSQueueMetrics) metrics;
}
Also used : QueueMetrics(org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 97 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.

the class FiCaSchedulerApp method findNodeToUnreserve.

@VisibleForTesting
public RMContainer findNodeToUnreserve(Resource clusterResource, FiCaSchedulerNode node, SchedulerRequestKey schedulerKey, Resource minimumUnreservedResource) {
    try {
        readLock.lock();
        // need to unreserve some other container first
        NodeId idToUnreserve = getNodeIdToUnreserve(schedulerKey, minimumUnreservedResource, rc, clusterResource);
        if (idToUnreserve == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("checked to see if could unreserve for app but nothing " + "reserved that matches for this app");
            }
            return null;
        }
        FiCaSchedulerNode nodeToUnreserve = ((CapacityScheduler) scheduler).getNode(idToUnreserve);
        if (nodeToUnreserve == null) {
            LOG.error("node to unreserve doesn't exist, nodeid: " + idToUnreserve);
            return null;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("unreserving for app: " + getApplicationId() + " on nodeId: " + idToUnreserve + " in order to replace reserved application and place it on node: " + node.getNodeID() + " needing: " + minimumUnreservedResource);
        }
        // headroom
        Resources.addTo(getHeadroom(), nodeToUnreserve.getReservedContainer().getReservedResource());
        return nodeToUnreserve.getReservedContainer();
    } finally {
        readLock.unlock();
    }
}
Also used : NodeId(org.apache.hadoop.yarn.api.records.NodeId) CapacityScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 98 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.

the class DelegationTokenRenewer method obtainSystemTokensForUser.

@VisibleForTesting
protected Token<?>[] obtainSystemTokensForUser(String user, final Credentials credentials) throws IOException, InterruptedException {
    // Get new hdfs tokens on behalf of this user
    UserGroupInformation proxyUser = UserGroupInformation.createProxyUser(user, UserGroupInformation.getLoginUser());
    Token<?>[] newTokens = proxyUser.doAs(new PrivilegedExceptionAction<Token<?>[]>() {

        @Override
        public Token<?>[] run() throws Exception {
            FileSystem fs = FileSystem.get(getConfig());
            try {
                return fs.addDelegationTokens(UserGroupInformation.getLoginUser().getUserName(), credentials);
            } finally {
                // Close the FileSystem created by the new proxy user,
                // So that we don't leave an entry in the FileSystem cache
                fs.close();
            }
        }
    });
    return newTokens;
}
Also used : FileSystem(org.apache.hadoop.fs.FileSystem) Token(org.apache.hadoop.security.token.Token) IOException(java.io.IOException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 99 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.

the class FifoScheduler method addApplicationAttempt.

@VisibleForTesting
public synchronized void addApplicationAttempt(ApplicationAttemptId appAttemptId, boolean transferStateFromPreviousAttempt, boolean isAttemptRecovering) {
    SchedulerApplication<FifoAppAttempt> application = applications.get(appAttemptId.getApplicationId());
    String user = application.getUser();
    // TODO: Fix store
    FifoAppAttempt schedulerApp = new FifoAppAttempt(appAttemptId, user, DEFAULT_QUEUE, activeUsersManager, this.rmContext);
    if (transferStateFromPreviousAttempt) {
        schedulerApp.transferStateFromPreviousAttempt(application.getCurrentAppAttempt());
    }
    application.setCurrentAppAttempt(schedulerApp);
    metrics.submitAppAttempt(user);
    LOG.info("Added Application Attempt " + appAttemptId + " to scheduler from user " + application.getUser());
    if (isAttemptRecovering) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(appAttemptId + " is recovering. Skipping notifying ATTEMPT_ADDED");
        }
    } else {
        rmContext.getDispatcher().getEventHandler().handle(new RMAppAttemptEvent(appAttemptId, RMAppAttemptEventType.ATTEMPT_ADDED));
    }
}
Also used : RMAppAttemptEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 100 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.

the class JobResourceUploader method getFileStatus.

@VisibleForTesting
FileStatus getFileStatus(Map<URI, FileStatus> statCache, Configuration job, Path p) throws IOException {
    URI u = p.toUri();
    FileStatus status = statCache.get(u);
    if (status == null) {
        status = p.getFileSystem(job).getFileStatus(p);
        statCache.put(u, status);
    }
    return status;
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) URI(java.net.URI) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1955 IOException (java.io.IOException)284 ArrayList (java.util.ArrayList)214 Map (java.util.Map)156 HashMap (java.util.HashMap)147 List (java.util.List)113 File (java.io.File)94 ImmutableMap (com.google.common.collect.ImmutableMap)72 HashSet (java.util.HashSet)67 Path (org.apache.hadoop.fs.Path)63 ImmutableList (com.google.common.collect.ImmutableList)60 Path (java.nio.file.Path)60 Set (java.util.Set)52 Matcher (java.util.regex.Matcher)46 Collectors (java.util.stream.Collectors)46 Collection (java.util.Collection)39 Optional (java.util.Optional)38 NotNull (org.jetbrains.annotations.NotNull)37 ImmutableSet (com.google.common.collect.ImmutableSet)34 TreeMap (java.util.TreeMap)34