Java Code Examples for build.bazel.remote.execution.v2.Platform#Property
The following examples show how to use
build.bazel.remote.execution.v2.Platform#Property .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionServer.java From bazel with Apache License 2.0 | 6 votes |
private static String dockerContainer(Command cmd) throws StatusException { String result = null; for (Platform.Property property : cmd.getPlatform().getPropertiesList()) { if (property.getName().equals(CONTAINER_IMAGE_ENTRY_NAME)) { if (result != null) { // Multiple container name entries throw StatusUtils.invalidArgumentError( "platform", // Field name. String.format( "Multiple entries for %s in action.Platform", CONTAINER_IMAGE_ENTRY_NAME)); } result = property.getValue(); if (!result.startsWith(DOCKER_IMAGE_PREFIX)) { throw StatusUtils.invalidArgumentError( "platform", // Field name. String.format( "%s: Docker images must be stored in gcr.io with an image spec in the form " + "'docker://gcr.io/{IMAGE_NAME}'", CONTAINER_IMAGE_ENTRY_NAME)); } result = result.substring(DOCKER_IMAGE_PREFIX.length()); } } return result; }
Example 2
Source File: ShardWorkerInstance.java From bazel-buildfarm with Apache License 2.0 | 6 votes |
@VisibleForTesting public QueueEntry dispatchOperation(MatchListener listener) throws IOException, InterruptedException { while (!backplane.isStopped()) { listener.onWaitStart(); try { List<Platform.Property> provisions = new ArrayList<>(); QueueEntry queueEntry = backplane.dispatchOperation(provisions); if (queueEntry != null) { return queueEntry; } } catch (IOException e) { Status status = Status.fromThrowable(e); if (status.getCode() != Code.UNAVAILABLE && status.getCode() != Code.DEADLINE_EXCEEDED) { throw e; } } listener.onWaitEnd(); } throw new IOException(Status.UNAVAILABLE.withDescription("backplane is stopped").asException()); }
Example 3
Source File: RedisShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
@Override public QueueEntry dispatchOperation(List<Platform.Property> provisions) throws IOException, InterruptedException { return client.blockingCall( jedis -> { return dispatchOperation(jedis, provisions); }); }
Example 4
Source File: PlatformUtils.java From bazel with Apache License 2.0 | 5 votes |
private static void sortPlatformProperties(Platform.Builder builder) { List<Platform.Property> properties = Ordering.from(Comparator.comparing(Platform.Property::getName)) .sortedCopy(builder.getPropertiesList()); builder.clearProperties(); builder.addAllProperties(properties); }
Example 5
Source File: SpawnLogContext.java From bazel with Apache License 2.0 | 5 votes |
private static Protos.Platform buildPlatform(Platform platform) { Protos.Platform.Builder platformBuilder = Protos.Platform.newBuilder(); for (Platform.Property p : platform.getPropertiesList()) { platformBuilder.addPropertiesBuilder().setName(p.getName()).setValue(p.getValue()); } return platformBuilder.build(); }
Example 6
Source File: ShardWorkerContext.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
static SetMultimap<String, String> getMatchProvisions( Platform platform, Iterable<ExecutionPolicy> policyNames, int executeStageWidth) { ImmutableSetMultimap.Builder<String, String> provisions = ImmutableSetMultimap.builder(); for (Platform.Property property : platform.getPropertiesList()) { provisions.put(property.getName(), property.getValue()); } for (ExecutionPolicy policy : policyNames) { String name = policy.getName(); if (!name.isEmpty()) { provisions.put("execution-policy", name); } } provisions.put("cores", String.format("%d", executeStageWidth)); return provisions.build(); }
Example 7
Source File: Actions.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
public static boolean satisfiesRequirements( SetMultimap<String, String> provisions, Platform requirements) { for (Platform.Property property : requirements.getPropertiesList()) { if (!satisfiesRequirement(provisions, property.getName(), property.getValue())) { return false; } } return true; }
Example 8
Source File: MemoryInstance.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
static SetMultimap<String, String> createProvisions(Platform platform) { ImmutableSetMultimap.Builder<String, String> provisions = ImmutableSetMultimap.builder(); for (Platform.Property property : platform.getPropertiesList()) { provisions.put(property.getName(), property.getValue()); } return provisions.build(); }
Example 9
Source File: RedisShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private void queue( JedisCluster jedis, String operationName, List<Platform.Property> provisions, String queueEntryJson) { if (jedis.hdel(config.getDispatchedOperationsHashName(), operationName) == 1) { logger.log(Level.WARNING, format("removed dispatched operation %s", operationName)); } operationQueue.push(jedis, provisions, queueEntryJson); }
Example 10
Source File: RedisShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private SetMultimap<String, String> toMultimap(List<Platform.Property> provisions) { SetMultimap<String, String> set = LinkedHashMultimap.create(); for (Platform.Property property : provisions) { set.put(property.getName(), property.getValue()); } return set; }
Example 11
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private SetMultimap<String, String> toMultimap(List<Platform.Property> provisions) { SetMultimap<String, String> set = LinkedHashMultimap.create(); for (Platform.Property property : provisions) { set.put(property.getName(), property.getValue()); } return set; }
Example 12
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private BalancedRedisQueue chooseEligibleQueue(List<Platform.Property> provisions) { for (ProvisionedRedisQueue provisionedQueue : queues) { if (provisionedQueue.isEligible(toMultimap(provisions))) { return provisionedQueue.queue(); } } throw new RuntimeException( "there are no eligible queues for the provided execution requirements. One solution to is to configure a provision queue with no requirements which would be eligible to all operations."); }
Example 13
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
public Boolean validProperties(List<Platform.Property> provisions) { for (ProvisionedRedisQueue provisionedQueue : queues) { if (provisionedQueue.isEligible(toMultimap(provisions))) { return true; } } return false; }
Example 14
Source File: RedisShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
@Override public Boolean validQueueProperties(List<Platform.Property> provisions) { return operationQueue.validProperties(provisions); }
Example 15
Source File: ShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
@ThreadSafe Boolean validQueueProperties(List<Platform.Property> provisions);
Example 16
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
public QueueStatus status(JedisCluster jedis, List<Platform.Property> provisions) { BalancedRedisQueue queue = chooseEligibleQueue(provisions); return queue.status(jedis); }
Example 17
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
public String dequeue(JedisCluster jedis, List<Platform.Property> provisions) throws InterruptedException { BalancedRedisQueue queue = chooseEligibleQueue(provisions); return queue.dequeue(jedis); }
Example 18
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
public void push(JedisCluster jedis, List<Platform.Property> provisions, String val) { BalancedRedisQueue queue = chooseEligibleQueue(provisions); queue.push(jedis, val); }
Example 19
Source File: OperationQueue.java From bazel-buildfarm with Apache License 2.0 | 4 votes |
public String getDequeueName(List<Platform.Property> provisions) { BalancedRedisQueue queue = chooseEligibleQueue(provisions); return queue.getDequeueName(); }
Example 20
Source File: ShardBackplane.java From bazel-buildfarm with Apache License 2.0 | 2 votes |
/** * The state of operations is tracked in a series of lists representing the order in which the * work is to be processed (queued, dispatched, and completed). * * <p>Moves an operation from the list of queued operations to the list of dispatched operations. */ @ThreadSafe QueueEntry dispatchOperation(List<Platform.Property> provisions) throws IOException, InterruptedException;