text:
// This is the backend code for reading and writing

// Generated by ProtocolBuffer
// - a pure c# code generation implementation of protocol buffers
// Report bugs to: https://silentorbit.com/protobuf/

// DO NOT EDIT
// This file will be overwritten when CodeGenerator is run.
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;

namespace Example
{
    [System.Serializable()]
    public partial class SCException
    {
        /// Helper: create a new instance to deserializing into
        public static SCException Deserialize(Stream stream)
        {
            SCException instance = new SCException();
            Deserialize(stream, instance);
            return instance;
        }

        /// Helper: create a new instance to deserializing into
        public static SCException DeserializeLengthDelimited(Stream stream)
        {
            SCException instance = new SCException();
            DeserializeLengthDelimited(stream, instance);
            return instance;
        }

        /// Helper: create a new instance to deserializing into
        public static SCException DeserializeLength(Stream stream, int length)
        {
            SCException instance = new SCException();
            DeserializeLength(stream, length, instance);
            return instance;
        }

        /// Helper: put the buffer into a MemoryStream and create a new instance to deserializing into
        public static SCException Deserialize(byte[] buffer)
        {
            SCException instance = new SCException();
            using (var ms = new MemoryStream(buffer))
                Deserialize(ms, instance);
            return instance;
        }

        /// Helper: put the buffer into a MemoryStream before deserializing
        public static Example.SCException Deserialize(byte[] buffer, Example.SCException instance)
        {
            using (var ms = new MemoryStream(buffer))
                Deserialize(ms, instance);
            return instance;
        }

        /// Takes the remaining content of the stream and deserialze it into the instance.
        public static Example.SCException Deserialize(Stream stream, Example.SCException instance)
        {
            while (true)
            {
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    break;
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 Varint
                    case 8:
                        instance.ErrCode = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.ErrMsg = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }

        /// Read the VarInt length prefix and the given number of bytes from the stream and deserialze it into the instance.
        public static Example.SCException DeserializeLengthDelimited(Stream stream, Example.SCException instance)
        {
            long limit = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt32(stream);
            limit += stream.Position;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 Varint
                    case 8:
                        instance.ErrCode = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.ErrMsg = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }

        /// Read the given number of bytes from the stream and deserialze it into the instance.
        public static Example.SCException DeserializeLength(Stream stream, int length, Example.SCException instance)
        {
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 Varint
                    case 8:
                        instance.ErrCode = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 2 LengthDelimited
                    case 18:
                        instance.ErrMsg = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }

        /// Serialize the instance into the stream
        public static void Serialize(Stream stream, SCException instance)
        {
            var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
            // Key for field: 1, Varint
            stream.WriteByte(8);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.ErrCode);
            if (instance.ErrMsg == null)
                throw new ArgumentNullException("ErrMsg", "Required by proto specification.");
            // Key for field: 2, LengthDelimited
            stream.WriteByte(18);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.ErrMsg));
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
        }

        /// Helper: Serialize into a MemoryStream and return its byte array
        public static byte[] SerializeToBytes(SCException instance)
        {
            using (var ms = new MemoryStream())
            {
                Serialize(ms, instance);
                return ms.ToArray();
            }
        }
        /// Helper: Serialize with a varint length prefix
        public static void SerializeLengthDelimited(Stream stream, SCException instance)
        {
            var data = SerializeToBytes(instance);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
            stream.Write(data, 0, data.Length);
        }
    }

}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="actionbar_height">45dip</dimen>
    <dimen name="actionbar_item_height">45dip</dimen>
    <dimen name="actionbar_item_width">45dip</dimen>
</resources>

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfApplicationLauncher.DataSourcing
{
    /// <summary>
    /// API entry point to provide search results to the application.
    /// </summary>
    public interface ISearchProvider
    {
        /// <summary>
        /// Used to display search provider in UI.
        /// </summary>
        String Title { get; }

        /// <summary>
        /// Ran after discovery by API.
        /// </summary>
        bool Initialize();

        /// <summary>
        /// Perform a search.
        /// </summary>
        /// <param name="words">Search words to use.</param>
        /// <returns><see cref="ISearchQuery"/> containing results.</returns>
        ISearchQuery Query(params String[] words);
    }
}


text:
package org.apache.hadoop.yarn.server.timelineservice.reader;

import java.io.IOException;
import java.util.Set;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.yarn.api.records.timelineservice.FlowActivityEntity;
import org.apache.hadoop.yarn.api.records.timelineservice.FlowRunEntity;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.security.AdminACLsManager;
import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader;

/**
 * This class wraps over the timeline reader store implementation. It does some
 * non trivial manipulation of the timeline data before or after getting
 * it from the backend store.
 */
@Private
@Unstable
public class TimelineReaderManager extends AbstractService {

  private TimelineReader reader;
  private AdminACLsManager adminACLsManager;

  public TimelineReaderManager(TimelineReader timelineReader) {
    super(TimelineReaderManager.class.getName());
    this.reader = timelineReader;
  }

  @Override
  protected void serviceInit(Configuration conf) throws Exception {
    // TODO Once ACLS story is played, this need to be removed or modified.
    this.adminACLsManager = new AdminACLsManager(conf);
  }

  /**
   * Gets cluster ID from config yarn.resourcemanager.cluster-id
   * if not supplied by client.
   * @param clusterId
   * @param conf
   * @return clusterId
   */
  private static String getClusterID(String clusterId, Configuration conf) {
    if (clusterId == null || clusterId.isEmpty()) {
      return conf.get(
          YarnConfiguration.RM_CLUSTER_ID,
              YarnConfiguration.DEFAULT_RM_CLUSTER_ID);
    }
    return clusterId;
  }

  private static TimelineEntityType getTimelineEntityType(String entityType) {
    if (entityType == null) {
      return null;
    }
    try {
      return TimelineEntityType.valueOf(entityType);
    } catch (IllegalArgumentException e) {
      return null;
    }
  }

  /**
   * Fill UID in the info field of entity based on the query(identified by
   * entity type).
   * @param entityType Entity type of query.
   * @param entity Timeline Entity.
   * @param context Context defining the query.
   */
  private static void fillUID(TimelineEntityType entityType,
      TimelineEntity entity, TimelineReaderContext context) {
    if (entityType != null) {
      switch(entityType) {
      case YARN_FLOW_ACTIVITY:
        FlowActivityEntity activityEntity = (FlowActivityEntity)entity;
        context.setUserId(activityEntity.getUser());
        context.setFlowName(activityEntity.getFlowName());
        entity.setUID(TimelineReaderUtils.UID_KEY,
            TimelineUIDConverter.FLOW_UID.encodeUID(context));
        return;
      case YARN_FLOW_RUN:
        FlowRunEntity runEntity = (FlowRunEntity)entity;
        context.setFlowRunId(runEntity.getRunId());
        entity.setUID(TimelineReaderUtils.UID_KEY,
            TimelineUIDConverter.FLOWRUN_UID.encodeUID(context));
        return;
      case YARN_APPLICATION:
        context.setAppId(entity.getId());
        entity.setUID(TimelineReaderUtils.UID_KEY,
            TimelineUIDConverter.APPLICATION_UID.encodeUID(context));
        return;
      default:
        break;
      }
    }
    context.setEntityType(entity.getType());
    context.setEntityIdPrefix(entity.getIdPrefix());
    context.setEntityId(entity.getId());
    if (context.getDoAsUser() != null) {
      entity.setUID(TimelineReaderUtils.UID_KEY,
          TimelineUIDConverter.SUB_APPLICATION_ENTITY_UID.encodeUID(context));
    } else {
      entity.setUID(TimelineReaderUtils.UID_KEY,
          TimelineUIDConverter.GENERIC_ENTITY_UID.encodeUID(context));
    }
  }

  /**
   * Get a set of entities matching given predicates by making a call to
   * backend storage implementation. The meaning of each argument has been
   * documented in detail with {@link TimelineReader#getEntities}.If cluster ID
   * has not been supplied by the client, fills the cluster id from config
   * before making a call to backend storage. After fetching entities from
   * backend, fills the appropriate UID based on entity type for each entity.
   *
   * @param context Timeline context within the scope of which entities have to
   *     be fetched.
   * @param filters Filters which limit the number of entities to be returned.
   * @param dataToRetrieve Data to carry in each entity fetched.
   * @return a set of TimelineEntity objects.
   * @throws IOException if any problem occurs while getting entities.
   * @see TimelineReader#getEntities
   */
  public Set<TimelineEntity> getEntities(TimelineReaderContext context,
      TimelineEntityFilters filters, TimelineDataToRetrieve dataToRetrieve)
      throws IOException {
    context.setClusterId(getClusterID(context.getClusterId(), getConfig()));
    Set<TimelineEntity> entities = reader.getEntities(
        new TimelineReaderContext(context), filters, dataToRetrieve);
    if (entities != null) {
      TimelineEntityType type = getTimelineEntityType(context.getEntityType());
      for (TimelineEntity entity : entities) {
        fillUID(type, entity, context);
      }
    }
    return entities;
  }

  /**
   * Get single timeline entity by making a call to backend storage
   * implementation. The meaning of each argument in detail has been
   * documented with {@link TimelineReader#getEntity}. If cluster ID has not
   * been supplied by the client, fills the cluster id from config before making
   * a call to backend storage. After fetching entity from backend, fills the
   * appropriate UID based on entity type.
   *
   * @param context Timeline context within the scope of which entity has to be
   *     fetched.
   * @param dataToRetrieve Data to carry in the entity fetched.
   * @return A TimelineEntity object if found, null otherwise.
   * @throws IOException  if any problem occurs while getting entity.
   * @see TimelineReader#getEntity
   */
  public TimelineEntity getEntity(TimelineReaderContext context,
      TimelineDataToRetrieve dataToRetrieve) throws IOException {
    context.setClusterId(
        getClusterID(context.getClusterId(), getConfig()));
    TimelineEntity entity = reader.getEntity(
        new TimelineReaderContext(context), dataToRetrieve);
    if (entity != null) {
      TimelineEntityType type = getTimelineEntityType(context.getEntityType());
      fillUID(type, entity, context);
    }
    return entity;
  }

  /**
   * Gets a list of available timeline entity types for an application. This can
   * be done by making a call to the backend storage implementation. The meaning
   * of each argument in detail is the same as {@link TimelineReader#getEntity}.
   * If cluster ID has not been supplied by the client, fills the cluster id
   * from config before making a call to backend storage.
   *
   * @param context Timeline context within the scope of which entity types
   *                have to be fetched. Entity type field of this context should
   *                be null.
   * @return A set which contains available timeline entity types, represented
   * as strings if found, empty otherwise.
   * @throws IOException  if any problem occurs while getting entity types.
   */
  public Set<String> getEntityTypes(TimelineReaderContext context)
      throws IOException{
    context.setClusterId(getClusterID(context.getClusterId(), getConfig()));
    return reader.getEntityTypes(new TimelineReaderContext(context));
  }

  /**
   * The API to confirm is a User is allowed to read this data.
   * @param callerUGI UserGroupInformation of the user
   */
  public boolean checkAccess(UserGroupInformation callerUGI) {
    // TODO to be removed or modified once ACL story is played
    if (!adminACLsManager.areACLsEnabled()) {
      return true;
    }
    return callerUGI != null && adminACLsManager.isAdmin(callerUGI);
  }
}


text:
package org.elasticsearch.threadpool;

import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.apache.lucene.util.Counter;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsAbortPolicy;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node;

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static java.util.Collections.unmodifiableMap;

public class ThreadPool extends AbstractComponent implements Closeable {

    public static class Names {
        public static final String SAME = "same";
        public static final String GENERIC = "generic";
        public static final String LISTENER = "listener";
        public static final String GET = "get";
        public static final String INDEX = "index";
        public static final String BULK = "bulk";
        public static final String SEARCH = "search";
        public static final String MANAGEMENT = "management";
        public static final String FLUSH = "flush";
        public static final String REFRESH = "refresh";
        public static final String WARMER = "warmer";
        public static final String SNAPSHOT = "snapshot";
        public static final String FORCE_MERGE = "force_merge";
        public static final String FETCH_SHARD_STARTED = "fetch_shard_started";
        public static final String FETCH_SHARD_STORE = "fetch_shard_store";
    }

    public enum ThreadPoolType {
        DIRECT("direct"),
        FIXED("fixed"),
        SCALING("scaling");

        private final String type;

        public String getType() {
            return type;
        }

        ThreadPoolType(String type) {
            this.type = type;
        }

        private static final Map<String, ThreadPoolType> TYPE_MAP;

        static {
            Map<String, ThreadPoolType> typeMap = new HashMap<>();
            for (ThreadPoolType threadPoolType : ThreadPoolType.values()) {
                typeMap.put(threadPoolType.getType(), threadPoolType);
            }
            TYPE_MAP = Collections.unmodifiableMap(typeMap);
        }

        public static ThreadPoolType fromType(String type) {
            ThreadPoolType threadPoolType = TYPE_MAP.get(type);
            if (threadPoolType == null) {
                throw new IllegalArgumentException("no ThreadPoolType for " + type);
            }
            return threadPoolType;
        }
    }

    public static final Map<String, ThreadPoolType> THREAD_POOL_TYPES;

    static {
        HashMap<String, ThreadPoolType> map = new HashMap<>();
        map.put(Names.SAME, ThreadPoolType.DIRECT);
        map.put(Names.GENERIC, ThreadPoolType.SCALING);
        map.put(Names.LISTENER, ThreadPoolType.FIXED);
        map.put(Names.GET, ThreadPoolType.FIXED);
        map.put(Names.INDEX, ThreadPoolType.FIXED);
        map.put(Names.BULK, ThreadPoolType.FIXED);
        map.put(Names.SEARCH, ThreadPoolType.FIXED);
        map.put(Names.MANAGEMENT, ThreadPoolType.SCALING);
        map.put(Names.FLUSH, ThreadPoolType.SCALING);
        map.put(Names.REFRESH, ThreadPoolType.SCALING);
        map.put(Names.WARMER, ThreadPoolType.SCALING);
        map.put(Names.SNAPSHOT, ThreadPoolType.SCALING);
        map.put(Names.FORCE_MERGE, ThreadPoolType.FIXED);
        map.put(Names.FETCH_SHARD_STARTED, ThreadPoolType.SCALING);
        map.put(Names.FETCH_SHARD_STORE, ThreadPoolType.SCALING);
        THREAD_POOL_TYPES = Collections.unmodifiableMap(map);
    }

    private Map<String, ExecutorHolder> executors = new HashMap<>();

    private final ScheduledThreadPoolExecutor scheduler;

    private final EstimatedTimeThread estimatedTimeThread;

    static final Executor DIRECT_EXECUTOR = command -> command.run();

    private final ThreadContext threadContext;

    private final Map<String, ExecutorBuilder> builders;

    public Collection<ExecutorBuilder> builders() {
        return Collections.unmodifiableCollection(builders.values());
    }

    public static Setting<TimeValue> ESTIMATED_TIME_INTERVAL_SETTING =
        Setting.timeSetting("thread_pool.estimated_time_interval", TimeValue.timeValueMillis(200), Setting.Property.NodeScope);

    public ThreadPool(final Settings settings, final ExecutorBuilder<?>... customBuilders) {
        super(settings);

        assert Node.NODE_NAME_SETTING.exists(settings);

        final Map<String, ExecutorBuilder> builders = new HashMap<>();
        final int availableProcessors = EsExecutors.numberOfProcessors(settings);
        final int halfProcMaxAt5 = halfNumberOfProcessorsMaxFive(availableProcessors);
        final int halfProcMaxAt10 = halfNumberOfProcessorsMaxTen(availableProcessors);
        final int genericThreadPoolMax = boundedBy(4 * availableProcessors, 128, 512);
        builders.put(Names.GENERIC, new ScalingExecutorBuilder(Names.GENERIC, 4, genericThreadPoolMax, TimeValue.timeValueSeconds(30)));
        builders.put(Names.INDEX, new FixedExecutorBuilder(settings, Names.INDEX, availableProcessors, 200));
        builders.put(Names.BULK, new FixedExecutorBuilder(settings, Names.BULK, availableProcessors, 50));
        builders.put(Names.GET, new FixedExecutorBuilder(settings, Names.GET, availableProcessors, 1000));
        builders.put(Names.SEARCH, new FixedExecutorBuilder(settings, Names.SEARCH, searchThreadPoolSize(availableProcessors), 1000));
        builders.put(Names.MANAGEMENT, new ScalingExecutorBuilder(Names.MANAGEMENT, 1, 5, TimeValue.timeValueMinutes(5)));
        // no queue as this means clients will need to handle rejections on listener queue even if the operation succeeded
        // the assumption here is that the listeners should be very lightweight on the listeners side
        builders.put(Names.LISTENER, new FixedExecutorBuilder(settings, Names.LISTENER, halfProcMaxAt10, -1));
        builders.put(Names.FLUSH, new ScalingExecutorBuilder(Names.FLUSH, 1, halfProcMaxAt5, TimeValue.timeValueMinutes(5)));
        builders.put(Names.REFRESH, new ScalingExecutorBuilder(Names.REFRESH, 1, halfProcMaxAt10, TimeValue.timeValueMinutes(5)));
        builders.put(Names.WARMER, new ScalingExecutorBuilder(Names.WARMER, 1, halfProcMaxAt5, TimeValue.timeValueMinutes(5)));
        builders.put(Names.SNAPSHOT, new ScalingExecutorBuilder(Names.SNAPSHOT, 1, halfProcMaxAt5, TimeValue.timeValueMinutes(5)));
        builders.put(Names.FETCH_SHARD_STARTED, new ScalingExecutorBuilder(Names.FETCH_SHARD_STARTED, 1, 2 * availableProcessors, TimeValue.timeValueMinutes(5)));
        builders.put(Names.FORCE_MERGE, new FixedExecutorBuilder(settings, Names.FORCE_MERGE, 1, -1));
        builders.put(Names.FETCH_SHARD_STORE, new ScalingExecutorBuilder(Names.FETCH_SHARD_STORE, 1, 2 * availableProcessors, TimeValue.timeValueMinutes(5)));
        for (final ExecutorBuilder<?> builder : customBuilders) {
            if (builders.containsKey(builder.name())) {
                throw new IllegalArgumentException("builder with name [" + builder.name() + "] already exists");
            }
            builders.put(builder.name(), builder);
        }
        this.builders = Collections.unmodifiableMap(builders);

        threadContext = new ThreadContext(settings);

        final Map<String, ExecutorHolder> executors = new HashMap<>();
        for (@SuppressWarnings("unchecked") final Map.Entry<String, ExecutorBuilder> entry : builders.entrySet()) {
            final ExecutorBuilder.ExecutorSettings executorSettings = entry.getValue().getSettings(settings);
            final ExecutorHolder executorHolder = entry.getValue().build(executorSettings, threadContext);
            if (executors.containsKey(executorHolder.info.getName())) {
                throw new IllegalStateException("duplicate executors with name [" + executorHolder.info.getName() + "] registered");
            }
            logger.debug("created thread pool: {}", entry.getValue().formatInfo(executorHolder.info));
            executors.put(entry.getKey(), executorHolder);
        }

        executors.put(Names.SAME, new ExecutorHolder(DIRECT_EXECUTOR, new Info(Names.SAME, ThreadPoolType.DIRECT)));
        this.executors = unmodifiableMap(executors);

        this.scheduler = new ScheduledThreadPoolExecutor(1, EsExecutors.daemonThreadFactory(settings, "scheduler"), new EsAbortPolicy());
        this.scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
        this.scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
        this.scheduler.setRemoveOnCancelPolicy(true);

        TimeValue estimatedTimeInterval = ESTIMATED_TIME_INTERVAL_SETTING.get(settings);
        this.estimatedTimeThread = new EstimatedTimeThread(EsExecutors.threadName(settings, "[timer]"), estimatedTimeInterval.millis());
        this.estimatedTimeThread.start();
    }

    public long estimatedTimeInMillis() {
        return estimatedTimeThread.estimatedTimeInMillis();
    }

    public Counter estimatedTimeInMillisCounter() {
        return estimatedTimeThread.counter;
    }

    public ThreadPoolInfo info() {
        List<Info> infos = new ArrayList<>();
        for (ExecutorHolder holder : executors.values()) {
            String name = holder.info.getName();
            // no need to have info on "same" thread pool
            if ("same".equals(name)) {
                continue;
            }
            infos.add(holder.info);
        }
        return new ThreadPoolInfo(infos);
    }

    public Info info(String name) {
        ExecutorHolder holder = executors.get(name);
        if (holder == null) {
            return null;
        }
        return holder.info;
    }

    public ThreadPoolStats stats() {
        List<ThreadPoolStats.Stats> stats = new ArrayList<>();
        for (ExecutorHolder holder : executors.values()) {
            String name = holder.info.getName();
            // no need to have info on "same" thread pool
            if ("same".equals(name)) {
                continue;
            }
            int threads = -1;
            int queue = -1;
            int active = -1;
            long rejected = -1;
            int largest = -1;
            long completed = -1;
            if (holder.executor() instanceof ThreadPoolExecutor) {
                ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor();
                threads = threadPoolExecutor.getPoolSize();
                queue = threadPoolExecutor.getQueue().size();
                active = threadPoolExecutor.getActiveCount();
                largest = threadPoolExecutor.getLargestPoolSize();
                completed = threadPoolExecutor.getCompletedTaskCount();
                RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
                if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
                    rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
                }
            }
            stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest, completed));
        }
        return new ThreadPoolStats(stats);
    }

    /**
     * Get the generic executor. This executor's {@link Executor#execute(Runnable)} method will run the Runnable it is given in
     * the {@link ThreadContext} of the thread that queues it.
     */
    public Executor generic() {
        return executor(Names.GENERIC);
    }

    /**
     * Get the executor with the given name. This executor's {@link Executor#execute(Runnable)} method will run the Runnable it is given in
     * the {@link ThreadContext} of the thread that queues it.
     */
    public Executor executor(String name) {
        Executor executor = executors.get(name).executor();
        if (executor == null) {
            throw new IllegalArgumentException("No executor found for [" + name + "]");
        }
        return executor;
    }

    public ScheduledExecutorService scheduler() {
        return this.scheduler;
    }

    /**
     * Schedules a periodic action that runs on the specified thread pool.
     *
     * @param command the action to take
     * @param interval the delay interval
     * @param executor The name of the thread pool on which to execute this task. {@link Names#SAME} means "execute on the scheduler thread",
     *             which there is only one of. Executing blocking or long running code on the {@link Names#SAME} thread pool should never
     *             be done as it can cause issues with the cluster
     * @return a {@link Cancellable} that can be used to cancel the subsequent runs of the command. If the command is running, it will
     *         not be interrupted.
     */
    public Cancellable scheduleWithFixedDelay(Runnable command, TimeValue interval, String executor) {
        return new ReschedulingRunnable(command, interval, executor, this);
    }

    /**
     * Schedules a one-shot command to run after a given delay. The command is not run in the context of the calling thread. To preserve the
     * context of the calling thread you may call threadPool.getThreadContext().preserveContext on the runnable before passing
     * it to this method.
     *
     * @param delay delay before the task executes
     * @param executor the name of the thread pool on which to execute this task. SAME means "execute on the scheduler thread" which changes the
     *        meaning of the ScheduledFuture returned by this method. In that case the ScheduledFuture will complete only when the command
     *        completes.
     * @param command the command to run
     * @return a ScheduledFuture who's get will return when the task is has been added to its target thread pool and throw an exception if
     *         the task is canceled before it was added to its target thread pool. Once the task has been added to its target thread pool
     *         the ScheduledFuture will cannot interact with it.
     * @throws EsRejectedExecutionException if the task cannot be scheduled for execution
     */
    public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command) {
        if (!Names.SAME.equals(executor)) {
            command = new ThreadedRunnable(command, executor(executor));
        }
        return scheduler.schedule(new LoggingRunnable(command), delay.millis(), TimeUnit.MILLISECONDS);
    }

    public void shutdown() {
        estimatedTimeThread.running = false;
        estimatedTimeThread.interrupt();
        scheduler.shutdown();
        for (ExecutorHolder executor : executors.values()) {
            if (executor.executor() instanceof ThreadPoolExecutor) {
                ((ThreadPoolExecutor) executor.executor()).shutdown();
            }
        }
    }

    public void shutdownNow() {
        estimatedTimeThread.running = false;
        estimatedTimeThread.interrupt();
        scheduler.shutdownNow();
        for (ExecutorHolder executor : executors.values()) {
            if (executor.executor() instanceof ThreadPoolExecutor) {
                ((ThreadPoolExecutor) executor.executor()).shutdownNow();
            }
        }
    }

    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
        boolean result = scheduler.awaitTermination(timeout, unit);
        for (ExecutorHolder executor : executors.values()) {
            if (executor.executor() instanceof ThreadPoolExecutor) {
                result &= ((ThreadPoolExecutor) executor.executor()).awaitTermination(timeout, unit);
            }
        }

        estimatedTimeThread.join(unit.toMillis(timeout));
        return result;
    }

    /**
     * Constrains a value between minimum and maximum values
     * (inclusive).
     *
     * @param value the value to constrain
     * @param min   the minimum acceptable value
     * @param max   the maximum acceptable value
     * @return min if value is less than min, max if value is greater
     * than value, otherwise value
     */
    static int boundedBy(int value, int min, int max) {
        return Math.min(max, Math.max(min, value));
    }

    static int halfNumberOfProcessorsMaxFive(int numberOfProcessors) {
        return boundedBy((numberOfProcessors + 1) / 2, 1, 5);
    }

    static int halfNumberOfProcessorsMaxTen(int numberOfProcessors) {
        return boundedBy((numberOfProcessors + 1) / 2, 1, 10);
    }

    static int twiceNumberOfProcessors(int numberOfProcessors) {
        return boundedBy(2 * numberOfProcessors, 2, Integer.MAX_VALUE);
    }

    public static int searchThreadPoolSize(int availableProcessors) {
        return ((availableProcessors * 3) / 2) + 1;
    }

    class LoggingRunnable implements Runnable {

        private final Runnable runnable;

        LoggingRunnable(Runnable runnable) {
            this.runnable = runnable;
        }

        @Override
        public void run() {
            try {
                runnable.run();
            } catch (Exception e) {
                logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to run {}", runnable.toString()), e);
                throw e;
            }
        }

        @Override
        public int hashCode() {
            return runnable.hashCode();
        }

        @Override
        public boolean equals(Object obj) {
            return runnable.equals(obj);
        }

        @Override
        public String toString() {
            return "[threaded] " + runnable.toString();
        }
    }

    class ThreadedRunnable implements Runnable {

        private final Runnable runnable;

        private final Executor executor;

        ThreadedRunnable(Runnable runnable, Executor executor) {
            this.runnable = runnable;
            this.executor = executor;
        }

        @Override
        public void run() {
            executor.execute(runnable);
        }

        @Override
        public int hashCode() {
            return runnable.hashCode();
        }

        @Override
        public boolean equals(Object obj) {
            return runnable.equals(obj);
        }

        @Override
        public String toString() {
            return "[threaded] " + runnable.toString();
        }
    }

    static class EstimatedTimeThread extends Thread {

        final long interval;
        final TimeCounter counter;
        volatile boolean running = true;
        volatile long estimatedTimeInMillis;

        EstimatedTimeThread(String name, long interval) {
            super(name);
            this.interval = interval;
            this.estimatedTimeInMillis = TimeValue.nsecToMSec(System.nanoTime());
            this.counter = new TimeCounter();
            setDaemon(true);
        }

        public long estimatedTimeInMillis() {
            return this.estimatedTimeInMillis;
        }

        @Override
        public void run() {
            while (running) {
                estimatedTimeInMillis = TimeValue.nsecToMSec(System.nanoTime());
                try {
                    Thread.sleep(interval);
                } catch (InterruptedException e) {
                    running = false;
                    return;
                }
            }
        }

        private class TimeCounter extends Counter {

            @Override
            public long addAndGet(long delta) {
                throw new UnsupportedOperationException();
            }

            @Override
            public long get() {
                return estimatedTimeInMillis;
            }
        }
    }

    static class ExecutorHolder {
        private final Executor executor;
        public final Info info;

        ExecutorHolder(Executor executor, Info info) {
            assert executor instanceof EsThreadPoolExecutor || executor == DIRECT_EXECUTOR;
            this.executor = executor;
            this.info = info;
        }

        Executor executor() {
            return executor;
        }
    }

    public static class Info implements Writeable, ToXContent {

        private final String name;
        private final ThreadPoolType type;
        private final int min;
        private final int max;
        private final TimeValue keepAlive;
        private final SizeValue queueSize;

        public Info(String name, ThreadPoolType type) {
            this(name, type, -1);
        }

        public Info(String name, ThreadPoolType type, int size) {
            this(name, type, size, size, null, null);
        }

        public Info(String name, ThreadPoolType type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue queueSize) {
            this.name = name;
            this.type = type;
            this.min = min;
            this.max = max;
            this.keepAlive = keepAlive;
            this.queueSize = queueSize;
        }

        public Info(StreamInput in) throws IOException {
            name = in.readString();
            type = ThreadPoolType.fromType(in.readString());
            min = in.readInt();
            max = in.readInt();
            keepAlive = in.readOptionalWriteable(TimeValue::new);
            queueSize = in.readOptionalWriteable(SizeValue::new);
        }

        @Override
        public void writeTo(StreamOutput out) throws IOException {
            out.writeString(name);
            out.writeString(type.getType());
            out.writeInt(min);
            out.writeInt(max);
            out.writeOptionalWriteable(keepAlive);
            out.writeOptionalWriteable(queueSize);
        }

        public String getName() {
            return this.name;
        }

        public ThreadPoolType getThreadPoolType() {
            return this.type;
        }

        public int getMin() {
            return this.min;
        }

        public int getMax() {
            return this.max;
        }

        @Nullable
        public TimeValue getKeepAlive() {
            return this.keepAlive;
        }

        @Nullable
        public SizeValue getQueueSize() {
            return this.queueSize;
        }

        @Override
        public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
            builder.startObject(name);
            builder.field(Fields.TYPE, type.getType());
            if (min != -1) {
                builder.field(Fields.MIN, min);
            }
            if (max != -1) {
                builder.field(Fields.MAX, max);
            }
            if (keepAlive != null) {
                builder.field(Fields.KEEP_ALIVE, keepAlive.toString());
            }
            if (queueSize == null) {
                builder.field(Fields.QUEUE_SIZE, -1);
            } else {
                builder.field(Fields.QUEUE_SIZE, queueSize.singles());
            }
            builder.endObject();
            return builder;
        }

        static final class Fields {
            static final String TYPE = "type";
            static final String MIN = "min";
            static final String MAX = "max";
            static final String KEEP_ALIVE = "keep_alive";
            static final String QUEUE_SIZE = "queue_size";
        }
    }

    /**
     * Returns true if the given service was terminated successfully. If the termination timed out,
     * the service is null this method will return false.
     */
    public static boolean terminate(ExecutorService service, long timeout, TimeUnit timeUnit) {
        if (service != null) {
            service.shutdown();
            try {
                if (service.awaitTermination(timeout, timeUnit)) {
                    return true;
                }
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
            service.shutdownNow();
        }
        return false;
    }

    /**
     * Returns true if the given pool was terminated successfully. If the termination timed out,
     * the service is null this method will return false.
     */
    public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) {
        if (pool != null) {
            try {
                pool.shutdown();
                try {
                    if (pool.awaitTermination(timeout, timeUnit)) {
                        return true;
                    }
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }
                // last resort
                pool.shutdownNow();
            } finally {
                IOUtils.closeWhileHandlingException(pool);
            }
        }
        return false;
    }

    @Override
    public void close() throws IOException {
        threadContext.close();
    }

    public ThreadContext getThreadContext() {
        return threadContext;
    }

    /**
     * This interface represents an object whose execution may be cancelled during runtime.
     */
    public interface Cancellable {

        /**
         * Cancel the execution of this object. This method is idempotent.
         */
        void cancel();

        /**
         * Check if the execution has been cancelled
         * @return true if cancelled
         */
        boolean isCancelled();
    }

    /**
     * This class encapsulates the scheduling of a {@link Runnable} that needs to be repeated on a interval. For example, checking a value
     * for cleanup every second could be done by passing in a Runnable that can perform the check and the specified interval between
     * executions of this runnable. NOTE: the runnable is only rescheduled to run again after completion of the runnable.
     *
     * For this class, completion means that the call to {@link Runnable#run()} returned or an exception was thrown and caught. In
     * case of an exception, this class will log the exception and reschedule the runnable for its next execution. This differs from the
     * {@link ScheduledThreadPoolExecutor#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)} semantics as an exception there would
     * terminate the rescheduling of the runnable.
     */
    static final class ReschedulingRunnable extends AbstractRunnable implements Cancellable {

        private final Runnable runnable;
        private final TimeValue interval;
        private final String executor;
        private final ThreadPool threadPool;

        private volatile boolean run = true;

        /**
         * Creates a new rescheduling runnable and schedules the first execution to occur after the interval specified
         *
         * @param runnable the {@link Runnable} that should be executed periodically
         * @param interval the time interval between executions
         * @param executor the executor where this runnable should be scheduled to run
         * @param threadPool the {@link ThreadPool} instance to use for scheduling
         */
        ReschedulingRunnable(Runnable runnable, TimeValue interval, String executor, ThreadPool threadPool) {
            this.runnable = runnable;
            this.interval = interval;
            this.executor = executor;
            this.threadPool = threadPool;
            threadPool.schedule(interval, executor, this);
        }

        @Override
        public void cancel() {
            run = false;
        }

        @Override
        public boolean isCancelled() {
            return run == false;
        }

        @Override
        public void doRun() {
            // always check run here since this may have been cancelled since the last execution and we do not want to run
            if (run) {
                runnable.run();
            }
        }

        @Override
        public void onFailure(Exception e) {
            threadPool.logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to run scheduled task [{}] on thread pool [{}]", runnable.toString(), executor), e);
        }

        @Override
        public void onRejection(Exception e) {
            run = false;
            if (threadPool.logger.isDebugEnabled()) {
                threadPool.logger.debug((Supplier<?>) () -> new ParameterizedMessage("scheduled task [{}] was rejected on thread pool [{}]", runnable, executor), e);
            }
        }

        @Override
        public void onAfter() {
            // if this has not been cancelled reschedule it to run again
            if (run) {
                try {
                    threadPool.schedule(interval, executor, this);
                } catch (final EsRejectedExecutionException e) {
                    onRejection(e);
                }
            }
        }
    }

    public static boolean assertNotScheduleThread(String reason) {
        assert Thread.currentThread().getName().contains("scheduler") == false :
            "Expected current thread [" + Thread.currentThread() + "] to not be the scheduler thread. Reason: [" + reason + "]";
        return true;
    }
}


text:
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Abp.AspNetCore.App.Controllers;
using Abp.Json;
using Abp.Web.Models;
using Shouldly;
using Xunit;

namespace Abp.AspNetCore.Tests
{
    public class Validation_Tests : AppTestBase
    {
        [Fact]
        public async Task Should_Work_With_Valid_Parameters_ActionResult()
        {
            // Act
            var response = await GetResponseAsStringAsync(
                GetUrl<ValidationTestController>(
                    nameof(ValidationTestController.GetContentValue),
                    new { value = 42 }
                )
            );

            response.ShouldBe("OK: 42");
        }

        [Fact]
        public async Task Should_Work_With_Valid_Parameters_JsonResult()
        {
            // Act
            var response = await GetResponseAsObjectAsync<AjaxResponse<ValidationTestController.ValidationTestArgument1>>(
                GetUrl<ValidationTestController>(
                    nameof(ValidationTestController.GetJsonValue),
                    new { value = 42 }
                )
            );

            response.Success.ShouldBeTrue();
            response.Result.Value.ShouldBe(42);
        }

        [Theory]
        [InlineData(-2)]
        [InlineData("undefined")]
        [InlineData(null)]
        public async Task Should_Not_Work_With_Invalid_Parameters(object value)
        {
            // Act
            var response = await GetResponseAsObjectAsync<AjaxResponse<ValidationTestController.ValidationTestArgument1>>(
                GetUrl<ValidationTestController>(
                    nameof(ValidationTestController.GetJsonValue),
                    new { value = value }
                ),
                HttpStatusCode.BadRequest
            );

            response.Success.ShouldBeFalse();
            response.Result.ShouldBeNull();
            response.Error.ShouldNotBeNull();
            response.Error.ValidationErrors.ShouldNotBeNull();
            response.Error.ValidationErrors[0].Members.Length.ShouldBe(1);
            response.Error.ValidationErrors[0].Members[0].ShouldBe("value");
        }

        [Fact]
        public async Task Should_Not_Work_With_Invalid_Parameters_No_Parameter_Provided()
        {
            // Act
            var response = await GetResponseAsObjectAsync<AjaxResponse<ValidationTestController.ValidationTestArgument1>>(
                GetUrl<ValidationTestController>(
                    nameof(ValidationTestController.GetJsonValue)
                ),
                HttpStatusCode.BadRequest
            );

            response.Success.ShouldBeFalse();
            response.Result.ShouldBeNull();
            response.Error.ShouldNotBeNull();
            response.Error.ValidationErrors.ShouldNotBeNull();
            response.Error.ValidationErrors[0].Members.Length.ShouldBe(1);
            response.Error.ValidationErrors[0].Members[0].ShouldBe("value");
        }

        [Fact]
        public async Task Should_Not_Work_With_Invalid_Parameters_Enum()
        {
            // Act
            var response = await PostAsync<AjaxResponse<ValidationTestController.ValidationTestArgument2>>(
                GetUrl<ValidationTestController>(
                    nameof(ValidationTestController.GetJsonValueWithEnum)
                ),
                new StringContent("{ \"value\": \"asd\" }", Encoding.UTF8, "application/json"),
                HttpStatusCode.BadRequest
            );

            response.Success.ShouldBeFalse();
            response.Result.ShouldBeNull();
            response.Error.ShouldNotBeNull();
            response.Error.ValidationErrors.Length.ShouldBe(1);
            response.Error.ValidationErrors.ShouldNotBeNull();
            response.Error.ValidationErrors[0].Members.Length.ShouldBe(1);
            response.Error.ValidationErrors[0].Members[0].ShouldBe("value");
        }
    }
}


text:
import socket
import logging
import errno

class TunnelConnection:
    _SAFE_ERRNOS = [errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN]

    def __init__(self, socket, channel, remoteEndpoint):
        self._socket = socket
        self._channel = channel
        self._remoteEndpoint = remoteEndpoint
        self._logger = logging.getLogger('ssh')
        self._shutdownToRemote = False
        self._shutdownFromRemote = False

    def remoteEndpoint(self):
        return self._remoteEndpoint

    def done(self):
        return self._shutdownFromRemote and self._shutdownToRemote

    def close(self):
        if not self.done():
            self._logger.debug("Shutting down SSH tunneling connection due script request")
        if not self._shutdownFromRemote:
            self._safeShutdown(self._socket, socket.SHUT_WR)
            self._shutdownFromRemote = True
        if not self._shutdownToRemote:
            self._safeShutdown(self._channel, socket.SHUT_WR)
            self._shutdownToRemote = True
        if self._channel is not None:
            self._channel.close()
            self._channel = None
        if self._socket is not None:
            self._socket.close()
            self._socket = None

    def selectableSockets(self):
        assert not self.done()
        if self._shutdownFromRemote and not self._shutdownToRemote:
            return [self._socket]
        elif not self._shutdownFromRemote and self._shutdownToRemote:
            return [self._channel]
        else:
            return [self._socket, self._channel]

    def work(self, readReadySockets):
        assert not self.done()
        self._workFromRemote(readReadySockets)
        self._workToRemote(readReadySockets)

    def _workFromRemote(self, readReadySockets):
        if self._shutdownFromRemote:
            assert self._channel not in readReadySockets
            return
        if self._channel in readReadySockets:
            data = self._channel.recv(2048)
            if len(data) != 0:
                try:
                    self._socket.send(data)
                except socket.error as e:
                    if e.errno not in self._SAFE_ERRNOS:
                        raise
                    data = ""
            if len(data) == 0:
                self._shutdownFromRemote = True
                self._safeShutdown(self._socket, socket.SHUT_WR)
                self._logger.debug("SSH forward channel got shutdown from remote")
                if self.done():
                    self._logger.debug("Both ends shutdown, closing connection")
                    self.close()

    def _workToRemote(self, readReadySockets):
        if self._shutdownToRemote:
            assert self._socket not in readReadySockets
            return
        if self._socket in readReadySockets:
            try:
                data = self._socket.recv(2048)
            except socket.error as e:
                if e.errno not in self._SAFE_ERRNOS:
                    raise
                data = ""
            if len(data) == 0:
                self._shutdownToRemote = True
                self._safeShutdown(self._channel, socket.SHUT_WR)
                self._logger.debug("SSH forward channel got shutdown from local")
                if self.done():
                    self._logger.debug("Both ends shutdown, closing connection")
                    self.close()
            else:
                self._channel.send(data)

    def _safeShutdown(self, thing, shutdownFlag):
        try:
            thing.shutdown(shutdownFlag)
        except socket.error as e:
            if e.errno not in self._SAFE_ERRNOS:
                raise


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Nat. Hist. Res. 1(2): 15 (1991)

#### Original name
Gyalideopsis formosana H. Harada & Vezda

### Remarks
null


text:
<?php

namespace News\Model;

class TopicModel extends AbstractModel
{

    const NAME = 'topic';

}


text:
<?php

namespace Zuccadev\ExceptioneerLaravel\Lumen;

use Exception;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler {

    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $e
     * @return void
     */
    public function report(Exception $e)
    {
        return app('exceptioneer')->report($e);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        return parent::render($request, $e);
    }

}


text:
<?php

/* TwigBundle:Exception:error.txt.twig */
class __TwigTemplate_cb13092e4eb05e798f368b8a950bf10347f430e0d03e31a09a67d73fd855d26d extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 1
        echo "Oops! An Error Occurred
=======================

The server returned a \"";
        // line 4
        echo (isset($context["status_code"]) ? $context["status_code"] : $this->getContext($context, "status_code"));
        echo " ";
        echo (isset($context["status_text"]) ? $context["status_text"] : $this->getContext($context, "status_text"));
        echo "\".

Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.
";
    }

    public function getTemplateName()
    {
        return "TwigBundle:Exception:error.txt.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  24 => 4,  19 => 1,);
    }
}


text:
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.DotNet.ProjectModel.Graph;

namespace Microsoft.DotNet.Cli.Compiler.Common
{
    public static class LibraryExporterExtensions
    {
        public static IEnumerable<LibraryExport> GetAllProjectTypeDependencies(this LibraryExporter exporter)
        {
            return
                exporter.GetDependencies(LibraryType.Project)
                    .Concat(exporter.GetDependencies(LibraryType.MSBuildProject));
        }

        public static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath)
        {
            if (!Directory.Exists(destinationPath))
            {
                Directory.CreateDirectory(destinationPath);
            }

            foreach (var asset in assets)
            {
                File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)), overwrite: true);
            }
        }

        public static void StructuredCopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath, string tempLocation)
        {
            if (!Directory.Exists(destinationPath))
            {
                Directory.CreateDirectory(destinationPath);
            }

            foreach (var asset in assets)
            {
                var targetName = ResolveTargetName(destinationPath, asset);
                var transformedFile = asset.GetTransformedFile(tempLocation);

                File.Copy(transformedFile, targetName, overwrite: true);
            }
        }

        private static string ResolveTargetName(string destinationPath, LibraryAsset asset)
        {
            string targetName;
            if (!string.IsNullOrEmpty(asset.RelativePath))
            {
                targetName = Path.Combine(destinationPath, asset.RelativePath);
                var destinationAssetPath = Path.GetDirectoryName(targetName);

                if (!Directory.Exists(destinationAssetPath))
                {
                    Directory.CreateDirectory(destinationAssetPath);
                }
            }
            else
            {
                targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath));
            }
            return targetName;
        }
    }
}


text:
#include <mrpt/vision.h>  // Precompiled headers

#include <mrpt/vision/CFeatureExtraction.h>

// Universal include for all versions of OpenCV
#include <mrpt/otherlibs/do_opencv_includes.h>

using namespace mrpt;
using namespace mrpt::vision;
using namespace mrpt::system;
using namespace std;

/************************************************************************************************
*								selectGoodFeaturesKLT  									        *
************************************************************************************************/
void CFeatureExtraction::selectGoodFeaturesKLT(
		const mrpt::utils::CImage		&inImg,
		CFeatureList		&feats,
		unsigned int		init_ID,
		unsigned int		nDesiredFeatures,
		void				*mask_ ) const
{
//#define VERBOSE_TIMING

#ifdef VERBOSE_TIMING
	CTicTac tictac;
#endif
		MRPT_START

		#if MRPT_HAS_OPENCV
        const unsigned int MAX_COUNT = 300;

		// Reinterpret opencv formal arguments
		CvMatrix *mask = reinterpret_cast<CvMatrix*>(mask_);

		// -----------------------------------------------------------------
		// Create OpenCV Local Variables
		// -----------------------------------------------------------------
		int				count = 0;
		int				nPts;

		CvImage img, cGrey;

#ifdef VERBOSE_TIMING
		tictac.Tic();
#endif
		img.attach( const_cast<IplImage*>(inImg.getAs<IplImage>()), false );	// Attach Image as IplImage and do not use ref counter
#ifdef VERBOSE_TIMING
		cout << "[KLT] Attach: " << tictac.Tac()*1000.0f << endl;
#endif
		if( img.channels() == 1 )
			cGrey = img;										// Input image is already 'grayscale'
		else
		{
			cGrey.create( cvGetSize( img ), 8, 1);
			cvCvtColor( img, cGrey, CV_BGR2GRAY );				// Convert input image into 'grayscale'
		}

		nDesiredFeatures <= 0 ? nPts = MAX_COUNT : nPts = nDesiredFeatures;

		std::vector<CvPoint2D32f> points(nPts);

		CvImage eig, temp;									// temporary and auxiliary images

#ifdef VERBOSE_TIMING
		tictac.Tic();
#endif
		eig.create( cvGetSize( cGrey ), 32, 1 );
		temp.create( cvGetSize( cGrey ), 32, 1 );
#ifdef VERBOSE_TIMING
		cout << "[KLT] Create: " << tictac.Tac()*1000.0f << endl;
#endif
		count = nPts;										// Number of points to find

#if 0	// Temporary debug
		{
			static int i=0;
			cvSaveImage( format("debug_map_%05i.bmp",++i).c_str(), cGrey);
		}
#endif
		// -----------------------------------------------------------------
		// Select good features with subpixel accuracy (USING HARRIS OR KLT)
		// -----------------------------------------------------------------
		if( options.featsType == featHarris )
		{
#ifdef VERBOSE_TIMING
			tictac.Tic();
#endif
			cvGoodFeaturesToTrack( cGrey, eig, temp, &points[0], &count,	// input and output data
				(double)options.harrisOptions.threshold,					// for rejecting weak local maxima ( with min_eig < threshold*max(eig_image) )
				(double)options.harrisOptions.min_distance,					// minimum distance between features
				mask ? (*mask) : static_cast<const CvMat*>(NULL),			// ROI
				(double)options.harrisOptions.radius,						// size of the block of pixels used
				1,															// use Harris
				options.harrisOptions.k );									// k factor for the Harris algorithm
#ifdef VERBOSE_TIMING
			cout << "[KLT] Find feats: " << tictac.Tac()*1000.0f << endl;
#endif
		}
		else
		{
#ifdef VERBOSE_TIMING
			tictac.Tic();
#endif
			cvGoodFeaturesToTrack( cGrey, eig, temp, &points[0], &count,	// input and output data
				(double)options.KLTOptions.threshold,						// for rejecting weak local maxima ( with min_eig < threshold*max(eig_image) )
				(double)options.KLTOptions.min_distance,					// minimum distance between features
				mask ? (*mask) : static_cast<const CvMat*>(NULL),			// ROI
				options.KLTOptions.radius,									// size of the block of pixels used
				0,															// use Kanade Lucas Tomasi
				0.04 );														// un-used parameter
#ifdef VERBOSE_TIMING
			cout << "[KLT]: Find feats: " << tictac.Tac()*1000.0f << endl;
#endif
		}

		if( nDesiredFeatures > 0 && count < nPts )
			cout << "\n[WARNING][selectGoodFeaturesKLT]: Only " << count << " of " << nDesiredFeatures << " points could be extracted in the image." << endl;

		if( options.FIND_SUBPIXEL )
		{
#ifdef VERBOSE_TIMING
			tictac.Tic();
#endif
			// Subpixel interpolation
			cvFindCornerSubPix( cGrey, &points[0], count,
				cvSize(3,3), cvSize(-1,-1),
				cvTermCriteria( CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.05 ));

#ifdef VERBOSE_TIMING
			cout << "[KLT] subpixel: " << tictac.Tac()*1000.0f << endl;
#endif
		}

		// -----------------------------------------------------------------
		// Fill output structure
		// -----------------------------------------------------------------
#ifdef VERBOSE_TIMING
		tictac.Tic();
#endif

		feats.clear();
		unsigned int	borderFeats = 0;
		unsigned int	nCFeats		= init_ID;
		int				i			= 0;
		const int		limit		= min( nPts, count );
		int				offset		= (int)this->options.patchSize/2 + 1;
		unsigned int	imgH		= inImg.getHeight();
		unsigned int	imgW		= inImg.getWidth();

		while( i < limit )
		{
			const int xBorderInf = (int)floor( points[i].x - options.patchSize/2 );
			const int xBorderSup = (int)floor( points[i].x + options.patchSize/2 );
			const int yBorderInf = (int)floor( points[i].y - options.patchSize/2 );
			const int yBorderSup = (int)floor( points[i].y + options.patchSize/2 );

			if( options.patchSize==0 || ( (xBorderSup < (int)imgW) && (xBorderInf > 0) && (yBorderSup < (int)imgH) && (yBorderInf > 0) ) )
			{
				CFeaturePtr ft = CFeature::Create();

				ft->type		= featKLT;
				ft->x			= points[i].x;				// X position
				ft->y			= points[i].y;				// Y position
				ft->track_status = status_TRACKED;		    // Feature Status
				ft->response	= 0.0;						// A value proportional to the quality of the feature (unused yet)
				ft->ID			= nCFeats++;				// Feature ID into extraction
				ft->patchSize	= options.patchSize;		// The size of the feature patch

				if( options.patchSize > 0 )
				{
					inImg.extract_patch(
						ft->patch,
						round( ft->x ) - offset,
						round( ft->y ) - offset,
						options.patchSize,
						options.patchSize );				// Image patch surronding the feature
				}

				feats.push_back( ft );

			} // end if
			else
				borderFeats++;

			i++;
		} // end while

#ifdef VERBOSE_TIMING
		cout << "[KLT] Create output: " << tictac.Tac()*1000.0f << endl;
#endif

		#else
			THROW_EXCEPTION("The MRPT has been compiled with MRPT_HAS_OPENCV=0 !");
		#endif

		MRPT_END

} // end of function

/*------------------------------------------------------------
					findMoreFeatures
-------------------------------------------------------------*/
void  CFeatureExtraction::findMoreFeatures( const mrpt::utils::CImage &img,
											const CFeatureList &inList,
											CFeatureList &outList,
											unsigned int nDesiredFeats) const
{
#if MRPT_HAS_OPENCV
	MRPT_START

	if( options.featsType == featHarris || options.featsType == featKLT )
	{
		// Mask the points already stored in the list
		CvMatrix mask( img.getHeight(), img.getWidth(), CV_8UC1 );
		CvScalar zero = cvRealScalar( 0.0 );
		CvScalar one = cvRealScalar( 1.0 );

		cvSet( mask, one );												// Set the whole mask to 1 initially

		CFeatureList::const_iterator itKLT;

		TFeatureID mxID = 0;

		for( itKLT = inList.begin(); itKLT != inList.end(); itKLT++ )
		{
			int cx = (int)(*itKLT)->x;
			int cy = (int)(*itKLT)->y;

			// Mask surronding pixels
			size_t xxI = max( 0, cx - 15 );
			size_t xxE = min( cx + 15, (int)mask.cols()-1 );
			size_t yyI = max( 0, cy - 15 );
			size_t yyE = min( cy + 15, (int)mask.rows()-1 );

			for(size_t yy = yyI; yy < yyE; yy++)
				for(size_t xx = xxI; xx < xxE; xx++)
					cvSet2D( mask, yy, xx, zero );

			if( (*itKLT)->ID > mxID )
				mxID = (*itKLT)->ID;

		}
		selectGoodFeaturesKLT( img, outList, mxID + 1, nDesiredFeats, &mask );
	}
	else if( options.featsType == featFAST )
	{
		TFeatureID mxID = inList.getMaxID();
		extractFeaturesFAST( img, outList, mxID+1 );		// Find all the possible FAST features

		// Delete all that are too close to the current ones
		CFeatureList::iterator			itOutList;
		CFeatureList::const_iterator	itInList;
		for( itInList = inList.begin(); itInList != inList.end(); ++itInList )
		{
			for( itOutList = outList.begin(); itOutList != outList.end(); )
			{
				if( fabs((*itOutList)->x-(*itInList)->x) < 15 ||  fabs((*itOutList)->y-(*itInList)->y) < 15 )
					itOutList = outList.erase( itOutList );
				else
					++itOutList;
			} // end-for
		} // end-for

		if( nDesiredFeats != 0 && outList.size() > nDesiredFeats )
			outList.resize( nDesiredFeats );
	}
	MRPT_END
#else
	THROW_EXCEPTION("MRPT was compiled without OpenCV")
#endif
} // end findMoreFeatures

/************************************************************************************************
*								extractFeaturesKLT												*
************************************************************************************************/
void  CFeatureExtraction::extractFeaturesKLT(
		const mrpt::utils::CImage			&img,
		CFeatureList			&feats,
		unsigned int			init_ID,
		unsigned int			nDesiredFeatures,
		const TImageROI			&ROI) const
{
#if MRPT_HAS_OPENCV
	// Get image size
	size_t imgW = img.getWidth();
	size_t imgH = img.getHeight();

	// Check image size and ROI limits
	ASSERT_( imgH > 0 && imgW > 0 );													// Proper Image Size
	ASSERT_( ROI.xMin >= 0 && ROI.yMin >= 0 && ROI.xMax < imgW && ROI.yMax < imgH );	// Proper TImageROI Limits

	// Mask
	CvMatrix mask( imgH, imgW, CV_8UC1 );
	CvScalar zero = cvRealScalar( 0.0 );
	CvScalar one = cvRealScalar( 1.0 );

	if( ROI.xMin == 0 && ROI.xMax == 0 && ROI.yMin == 0 && ROI.yMax == 0 )		// Use the whole image (except the borders)
	{
		if( options.patchSize == 0 )
			selectGoodFeaturesKLT( img, feats, init_ID, nDesiredFeatures, NULL );
		else
		{
			// We mask the borders of the image in order to get an appropiate patch (according to the patch size)
			// ---------------------------------------------------------------------
			// 00000000000000000000000000000000000
			// 00000000000000000000000000000000000
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00111111111111111111111111111111100
			// 00000000000000000000000000000000000
			// 00000000000000000000000000000000000

			cvSet( mask, one );												// Set the whole mask to 1 initially

			size_t border = (options.patchSize-1)/2 + 1;
			size_t xx,yy;													// Put outside of the "for"s to avoid errors in VC6
			for( xx = 0; xx < imgW; xx++ )
				for( yy = 0; yy < border; yy++ )
					cvSet2D( mask, yy, xx, zero );							// Set to 0 the pixels not to be processed

			for( xx = 0; xx < imgW; xx++ )
				for( yy = imgH - border; yy < imgH; yy++ )
					cvSet2D( mask, yy, xx, zero );							// Set to 0 the pixels not to be processed

			for( xx = 0; xx < border; xx++ )
				for( yy = border; yy < imgH - border; yy++ )
					cvSet2D( mask, yy, xx, zero ) ;							// Set to 0 the pixels not to be processed

			for( xx = imgW - border; xx < imgW; xx++ )
				for( yy = border; yy < imgH - border; yy++ )
					cvSet2D( mask, yy, xx, zero ) ;							// Set to 0 the pixels not to be processed

			selectGoodFeaturesKLT( img, feats, init_ID, nDesiredFeatures, &mask );
		} // end if-else patchSize == 0
	} // end if ROI does not exist
	else
	{
		cvSet( mask, zero );												// Set the whole mask to 0 initially
		for( unsigned int xx = ROI.xMin; xx < ROI.xMax; xx++ )
			for( unsigned int yy = ROI.yMin; yy < ROI.yMax; yy++ )
				cvSet2D( mask, yy, xx, one) ;								// Set to 1 the pixels to be processed

		selectGoodFeaturesKLT( img, feats, init_ID, nDesiredFeatures, &mask );
	} // end if-else there exists a ROI
#else
	THROW_EXCEPTION("MRPT was compiled without OpenCV")
#endif
}


text:
package org.apache.hadoop.mapred;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.URI;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.mapred.lib.IdentityMapper;
import org.apache.hadoop.mapred.lib.IdentityReducer;
import org.apache.hadoop.mapreduce.MRConfig;
import org.apache.hadoop.mapreduce.SleepJob;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
import org.apache.hadoop.mapreduce.server.jobtracker.JTConfig;
import org.apache.hadoop.mapreduce.split.JobSplit.SplitMetaInfo;
import org.apache.hadoop.util.ToolRunner;

import junit.framework.TestCase;

/**
 * Test job submission. This test checks if
 *   - basic   : job submission via jobclient
 *   - cleanup : job client crashes while submitting
 *   - invalid job config
 *     - invalid memory config
 *
 */
public class TestSubmitJob extends TestCase {
  static final Log LOG = LogFactory.getLog(TestSubmitJob.class);

  private MiniMRCluster mrCluster;

  private MiniDFSCluster dfsCluster;
  private JobTracker jt;
  private FileSystem fs;
  private static Path TEST_DIR =
    new Path(System.getProperty("test.build.data","/tmp"),
             "job-submission-testing");
  private static int numSlaves = 1;

  private void startCluster() throws Exception {
    super.setUp();
    Configuration conf = new Configuration();
    dfsCluster = new MiniDFSCluster(conf, numSlaves, true, null);
    JobConf jConf = new JobConf(conf);
    jConf.setLong("mapred.job.submission.expiry.interval", 6 * 1000);
    mrCluster = new MiniMRCluster(0, 0, numSlaves,
        dfsCluster.getFileSystem().getUri().toString(), 1, null, null, null,
        jConf);
    jt = mrCluster.getJobTrackerRunner().getJobTracker();
    fs = FileSystem.get(mrCluster.createJobConf());
  }

  private void stopCluster() throws Exception {
    mrCluster.shutdown();
    mrCluster = null;
    dfsCluster.shutdown();
    dfsCluster = null;
    jt = null;
    fs = null;
  }

  /**
   * Test to verify that jobs with invalid memory requirements are killed at the
   * JT.
   *
   * @throws Exception
   */
  public void testJobWithInvalidMemoryReqs()
      throws Exception {
    JobConf jtConf = new JobConf();
    jtConf
        .setLong(MRConfig.MAPMEMORY_MB, 1 * 1024L);
    jtConf.setLong(MRConfig.REDUCEMEMORY_MB,
        2 * 1024L);
    jtConf.setLong(JTConfig.JT_MAX_MAPMEMORY_MB,
        3 * 1024L);
    jtConf.setLong(JTConfig.JT_MAX_REDUCEMEMORY_MB,
        4 * 1024L);

    mrCluster = new MiniMRCluster(0, "file:///", 0, null, null, jtConf);

    JobConf clusterConf = mrCluster.createJobConf();

    // No map-memory configuration
    JobConf jobConf = new JobConf(clusterConf);
    jobConf.setMemoryForReduceTask(1 * 1024L);
    runJobAndVerifyFailure(jobConf, JobConf.DISABLED_MEMORY_LIMIT, 1 * 1024L,
        "Invalid job requirements.");

    // No reduce-memory configuration
    jobConf = new JobConf(clusterConf);
    jobConf.setMemoryForMapTask(1 * 1024L);
    runJobAndVerifyFailure(jobConf, 1 * 1024L, JobConf.DISABLED_MEMORY_LIMIT,
        "Invalid job requirements.");

    // Invalid map-memory configuration
    jobConf = new JobConf(clusterConf);
    jobConf.setMemoryForMapTask(4 * 1024L);
    jobConf.setMemoryForReduceTask(1 * 1024L);
    runJobAndVerifyFailure(jobConf, 4 * 1024L, 1 * 1024L,
        "Exceeds the cluster's max-memory-limit.");

    // No reduce-memory configuration
    jobConf = new JobConf(clusterConf);
    jobConf.setMemoryForMapTask(1 * 1024L);
    jobConf.setMemoryForReduceTask(5 * 1024L);
    runJobAndVerifyFailure(jobConf, 1 * 1024L, 5 * 1024L,
        "Exceeds the cluster's max-memory-limit.");

    mrCluster.shutdown();
    mrCluster = null;
  }

  private void runJobAndVerifyFailure(JobConf jobConf, long memForMapTasks,
      long memForReduceTasks, String expectedMsg)
      throws Exception,
      IOException {
    String[] args = { "-m", "0", "-r", "0", "-mt", "0", "-rt", "0" };
    boolean throwsException = false;
    String msg = null;
    try {
      ToolRunner.run(jobConf, new SleepJob(), args);
    } catch (RemoteException re) {
      throwsException = true;
      msg = re.unwrapRemoteException().getMessage();
    }
    assertTrue(throwsException);
    assertNotNull(msg);

    String overallExpectedMsg =
        "(" + memForMapTasks + " memForMapTasks " + memForReduceTasks
            + " memForReduceTasks): " + expectedMsg;
    assertTrue("Observed message - " + msg
        + " - doesn't contain expected message - " + overallExpectedMsg, msg
        .contains(overallExpectedMsg));
  }

  static ClientProtocol getJobSubmitClient(JobConf conf,
                                           UserGroupInformation ugi)
  throws IOException {
    return (ClientProtocol) RPC.getProxy(ClientProtocol.class,
        ClientProtocol.versionID, JobTracker.getAddress(conf), ugi,
        conf, NetUtils.getSocketFactory(conf, ClientProtocol.class));
  }

  static org.apache.hadoop.hdfs.protocol.ClientProtocol getDFSClient(
      Configuration conf, UserGroupInformation ugi)
  throws IOException {
    return (org.apache.hadoop.hdfs.protocol.ClientProtocol)
      RPC.getProxy(org.apache.hadoop.hdfs.protocol.ClientProtocol.class,
        org.apache.hadoop.hdfs.protocol.ClientProtocol.versionID,
        NameNode.getAddress(conf), ugi,
        conf,
        NetUtils.getSocketFactory(conf,
            org.apache.hadoop.hdfs.protocol.ClientProtocol.class));
  }

  /**
   * Submit a job and check if the files are accessible to other users.
   */
  public void testSecureJobExecution() throws Exception {
    LOG.info("Testing secure job submission/execution");
    MiniMRCluster mr = null;
    Configuration conf = new Configuration();
    final MiniDFSCluster dfs = new MiniDFSCluster(conf, 1, true, null);
    try {
      FileSystem fs =
        TestMiniMRWithDFSWithDistinctUsers.DFS_UGI.doAs(new PrivilegedExceptionAction<FileSystem>() {
          public FileSystem run() throws IOException {
            return dfs.getFileSystem();
          }
        });
      TestMiniMRWithDFSWithDistinctUsers.mkdir(fs, "/user", "mapred", "mapred", (short)01777);
      TestMiniMRWithDFSWithDistinctUsers.mkdir(fs, "/mapred", "mapred", "mapred", (short)01777);
      TestMiniMRWithDFSWithDistinctUsers.mkdir(fs, conf.get(JTConfig.JT_STAGING_AREA_ROOT),
                                               "mapred", "mapred", (short)01777);

      UserGroupInformation MR_UGI = UserGroupInformation.getLoginUser();
      mr = new MiniMRCluster(0, 0, 1, dfs.getFileSystem().getUri().toString(),
                             1, null, null, MR_UGI);
      JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
      String jobTrackerName = "localhost:" + mr.getJobTrackerPort();

      // cleanup
      dfs.getFileSystem().delete(TEST_DIR, true);

      final Path mapSignalFile = new Path(TEST_DIR, "map-signal");
      final Path reduceSignalFile = new Path(TEST_DIR, "reduce-signal");

      // create a ugi for user 1
      UserGroupInformation user1 =
        TestMiniMRWithDFSWithDistinctUsers.createUGI("user1", false);
      Path inDir = new Path("/user/input");
      Path outDir = new Path("/user/output");
      final JobConf job = mr.createJobConf();

      UtilsForTests.configureWaitingJobConf(job, inDir, outDir, 2, 0,
        "test-submit-job", mapSignalFile.toString(),
        reduceSignalFile.toString());
      job.set(UtilsForTests.getTaskSignalParameter(true),
      mapSignalFile.toString());
      job.set(UtilsForTests.getTaskSignalParameter(false),
      reduceSignalFile.toString());
      LOG.info("Submit job as the actual user (" + user1.getUserName() + ")");
      final JobClient jClient =
        user1.doAs(new PrivilegedExceptionAction<JobClient>() {
          public JobClient run() throws IOException {
            return new JobClient(job);
          }
        });
      RunningJob rJob = user1.doAs(new PrivilegedExceptionAction<RunningJob>() {
        public RunningJob run() throws IOException {
          return jClient.submitJob(job);
        }
      });
      JobID id = rJob.getID();
      LOG.info("Running job " + id);

      // create user2
      UserGroupInformation user2 =
        TestMiniMRWithDFSWithDistinctUsers.createUGI("user2", false);
      JobConf conf_other = mr.createJobConf();
      org.apache.hadoop.hdfs.protocol.ClientProtocol client =
        getDFSClient(conf_other, user2);

      // try accessing mapred.system.dir/jobid/*
      try {
        String path = new URI(jt.getSystemDir()).getPath();
        LOG.info("Try listing the mapred-system-dir as the user ("
                 + user2.getUserName() + ")");
        client.getListing(path, HdfsFileStatus.EMPTY_NAME, false);
        fail("JobTracker system dir is accessible to others");
      } catch (IOException ioe) {
        assertTrue(ioe.toString(),
          ioe.toString().contains("Permission denied"));
      }
      // try accessing ~/.staging/jobid/*
      JobInProgress jip = jt.getJob(id);
      Path jobSubmitDirpath =
        new Path(jip.getJobConf().get("mapreduce.job.dir"));
      try {
        LOG.info("Try accessing the job folder for job " + id + " as the user ("
                 + user2.getUserName() + ")");
        client.getListing(jobSubmitDirpath.toUri().getPath(),
          HdfsFileStatus.EMPTY_NAME, false);
        fail("User's staging folder is accessible to others");
      } catch (IOException ioe) {
        assertTrue(ioe.toString(),
          ioe.toString().contains("Permission denied"));
      }
      UtilsForTests.signalTasks(dfs, fs, true, mapSignalFile.toString(),
      reduceSignalFile.toString());
      // wait for job to be done
      UtilsForTests.waitTillDone(jClient);

      // check if the staging area is cleaned up
      LOG.info("Check if job submit dir is cleanup or not");
      assertFalse(fs.exists(jobSubmitDirpath));
    } finally {
      if (mr != null) {
        mr.shutdown();
      }
      if (dfs != null) {
        dfs.shutdown();
      }
    }
  }
}


text:
from setuptools import find_packages, setup

install_requires = [
    "six",
    "content-io >= 1.2.5",
    "simplejson >= 3.2.0",
]

tests_require = [
    "coverage",
    "Markdown <= 3.3.0",
    "Pillow",
]

version = __import__("djedi").__version__

setup(
    name="djedi-cms",
    version=version,
    description="Django content management as it should be",
    long_description=(
        ".. image:: https://djedi-cms.org/_static/djedi-portrait.svg\n\n"
        "- Read the documentation_\n"
        "- Browse the source_\n\n"
        ".. image:: https://github.com/5monkeys/djedi-cms/workflows/CI/badge.svg\n"
        "    :target: https://github.com/5monkeys/djedi-cms/actions\n\n"
        ".. image:: https://coveralls.io/repos/5monkeys/djedi-cms/badge.svg?branch=master\n"
        "    :target: https://coveralls.io/r/5monkeys/djedi-cms?branch=master\n\n"
        ".. _documentation: https://djedi-cms.org/\n"
        ".. _source: https://github.com/5monkeys/djedi-cms\n\n"
    ),
    author="Jonas Lundberg",
    author_email="jonas@5monkeys.se",
    url="https://github.com/5monkeys/djedi-cms",
    download_url="https://github.com/5monkeys/djedi-cms/tarball/%s" % version,
    keywords=[
        "cms",
        "django",
        "edit",
        "gettext",
        "content",
        "management",
        "template",
        "plugins",
        "markdown",
    ],
    license="BSD",
    packages=find_packages(),
    include_package_data=True,
    zip_safe=False,
    classifiers=[
        "Environment :: Web Environment",
        "Natural Language :: English",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: BSD License",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
        "Topic :: Software Development :: Libraries :: Python Modules",
    ],
    install_requires=install_requires,
    extras_require={
        "tests": tests_require,
    },
    tests_require=tests_require,
    test_suite="runtests.main",
)


text:
'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _keys = require('babel-runtime/core-js/object/keys');

var _keys2 = _interopRequireDefault(_keys);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _UploadInput = require('./UploadInput');

var _UploadInput2 = _interopRequireDefault(_UploadInput);

var _FilesInProgress = require('./FilesInProgress');

var _FilesInProgress2 = _interopRequireDefault(_FilesInProgress);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var FileUploader = function (_React$Component) {
    (0, _inherits3.default)(FileUploader, _React$Component);

    function FileUploader(props) {
        (0, _classCallCheck3.default)(this, FileUploader);

        var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props));

        _this.state = { files: {}, percents: {} };
        _this.onProgress = function (_ref) {
            var percent = _ref.percent,
                uploadId = _ref.uploadId;

            var percents = _this.state.percents;
            percents[uploadId] = percent;
            _this.setState(percents);
            if (_this.props.onProgress) {
                _this.props.onProgress({ percent: percent, uploadId: uploadId });
            }
        };

        _this.onFileLoad = function (_ref2) {
            var file = _ref2.file,
                uploadId = _ref2.uploadId;

            var files = _this.state.files;
            files[uploadId] = file;
            _this.setState(files);
            if (_this.props.onFileLoad) {
                _this.props.onFileLoad({ file: file, uploadId: uploadId });
            }
        };

        _this.onUpload = function (params, done) {
            if (_this.props.onUpload) {
                _this.props.onUpload(params, done);
            }
        };

        _this.onFileUploaded = function (uploadId) {
            var _this$state = _this.state,
                files = _this$state.files,
                percents = _this$state.percents;

            delete files[uploadId];
            delete percents[uploadId];
            _this.setState(files);
            if (_this.props.onFileUploaded) {
                _this.props.onFileUploaded(uploadId);
            }
        };
        return _this;
    }

    FileUploader.prototype.render = function render() {
        var _state = this.state,
            _state$files = _state.files,
            files = _state$files === undefined ? {} : _state$files,
            _state$percents = _state.percents,
            percents = _state$percents === undefined ? {} : _state$percents;

        var filesArr = (0, _keys2.default)(files).map(function (uploadId) {
            var file = files[uploadId];
            var percent = percents[uploadId] || 0;
            return { file: file, percent: percent, uploadId: uploadId };
        });
        var props = _lodash2.default.omit(this.props, ['onFileLoad', 'onFileUploaded', 'onProgress']);
        props.label = props.label || 'Add File';
        return _react2.default.createElement(
            'div',
            null,
            _react2.default.createElement(_UploadInput2.default, (0, _extends3.default)({
                onFileLoad: this.onFileLoad,
                onUpload: this.onUpload,
                onFileUploaded: this.onFileUploaded,
                onProgress: this.onProgress
            }, props)),
            _react2.default.createElement(_FilesInProgress2.default, { files: filesArr })
        );
    };

    return FileUploader;
}(_react2.default.Component);

exports.default = FileUploader;


text:
            <img class="preview-conversation-skin-row-avatar-img rounded-circle" ng-src="<[userBlueImgUrl]>" >

            <angular-html-bind html-data="$ctrl.getInputTemplate()"></angular-html-bind>

      <md-card class="preview-conversation-skin-supplemental-card">

          <angular-html-bind html-data="$ctrl.getInputTemplate()">
          </angular-html-bind>

      </md-card>

    <md-button class="oppia-learner-confirm-button protractor-test-submit-answer-button"
               ng-disabled="isSubmitButtonDisabled()"
               ng-click="onSubmitAnswerFromButton()"
               translate="I18N_INTERACTIONS_SUBMIT">
    </md-button>


text:
package com.asha.vrlib.plugins;

import android.content.Context;

import com.asha.vrlib.MD360Director;
import com.asha.vrlib.model.MDPosition;

/**
 * Created by hzqiujiadi on 16/7/21.
 * hzqiujiadi ashqalcn@gmail.com
 */
public abstract class MDAbsPlugin {

    private boolean mIsInit;

    private long mTid;

    private MDPosition mPosition = MDPosition.getOriginalPosition();

    public final void setupInGL(Context context){
        long tid = Thread.currentThread().getId();
        if (tid != mTid) {
            mTid = tid;
            mIsInit = false;
        }

        if (!mIsInit){
            initInGL(context);
            mIsInit = true;
        }
    }

    abstract protected void initInGL(Context context);

    abstract public void destroyInGL();

    abstract public void beforeRenderer(int totalWidth, int totalHeight);

    abstract public void renderer(int index, int itemWidth, int itemHeight, MD360Director director);

    protected MDPosition getModelPosition(){
        return mPosition;
    }

    public void setModelPosition(MDPosition position) {
        this.mPosition = position;
    }

    abstract protected boolean removable();

}


text:
import logging

from google.appengine.ext import webapp, deferred, db

from rogerthat.rpc.models import OutStandingFirebaseKick
from rogerthat.rpc.rpc import firebase, PRIORITY_HIGH
from rogerthat.utils import now

class Reschedule(webapp.RequestHandler):

    def get(self):
        purge_timestamp = now()
        deferred.defer(fcm_kick, purge_timestamp)

def fcm_kick(from_):
    logging.info("Getting outstanding FCM kicks from datastore")
    outstanding_kicks = OutStandingFirebaseKick.all(keys_only=True).filter("timestamp <=", from_ - 300).order("timestamp")
    results = outstanding_kicks.fetch(1000)
    if not results:
        return
    logging.info("Bulk kicking registration_ids")
    registration_ids = list()
    for key in results:
        registration_ids.append(key.name())
    firebase.kick(registration_ids, PRIORITY_HIGH)
    db.delete(results)
    logging.info("Continue in 5 seconds ...")
    deferred.defer(fcm_kick, from_, _countdown=5)


text:
<!DOCTYPE html>

    <title>Eeasify Tests</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="test-styles.css">

Run Tests