Search in sources :

Example 1 with MemoryInstance

use of build.buildfarm.instance.memory.MemoryInstance in project bazel-buildfarm by bazelbuild.

the class BuildFarmInstances method createInstance.

public static Instance createInstance(String session, InstanceConfig instanceConfig, Runnable onStop) throws InterruptedException, ConfigurationException {
    String name = instanceConfig.getName();
    HashFunction hashFunction = getValidHashFunction(instanceConfig);
    DigestUtil digestUtil = new DigestUtil(hashFunction);
    Instance instance;
    switch(instanceConfig.getTypeCase()) {
        default:
        case TYPE_NOT_SET:
            throw new IllegalArgumentException("Instance type not set in config");
        case MEMORY_INSTANCE_CONFIG:
            instance = new MemoryInstance(name, digestUtil, instanceConfig.getMemoryInstanceConfig());
            break;
        case SHARD_INSTANCE_CONFIG:
            instance = new ShardInstance(name, session + "-" + name, digestUtil, instanceConfig.getShardInstanceConfig(), onStop);
            break;
    }
    return instance;
}
Also used : HashFunction(build.buildfarm.common.DigestUtil.HashFunction) MemoryInstance(build.buildfarm.instance.memory.MemoryInstance) Instance(build.buildfarm.instance.Instance) ShardInstance(build.buildfarm.instance.shard.ShardInstance) MemoryInstance(build.buildfarm.instance.memory.MemoryInstance) DigestUtil(build.buildfarm.common.DigestUtil) ShardInstance(build.buildfarm.instance.shard.ShardInstance)

Aggregations

DigestUtil (build.buildfarm.common.DigestUtil)1 HashFunction (build.buildfarm.common.DigestUtil.HashFunction)1 Instance (build.buildfarm.instance.Instance)1 MemoryInstance (build.buildfarm.instance.memory.MemoryInstance)1 ShardInstance (build.buildfarm.instance.shard.ShardInstance)1