scala.collection.Iterator<Address> endpointAddressesIterator = endpointAddresses.toIterator(); HashSet<ServiceInstance> serviceInstances = new HashSet<ServiceInstance>(); while (endpointAddressesIterator.hasNext()) {
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e->e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() != 1) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "%s valid endpoints available: %s", possibleEndpoints.size(), serverEndpoints )); } return possibleEndpoints.head(); }
private static Map<Resource, Set<Acl>> convertKafkaAclMap(scala.collection.immutable.Map<Resource, scala.collection.immutable.Set<Acl>> aclMap) { return Collections.unmodifiableMap(convertToJavaMap(aclMap.iterator()).entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> convertToJavaSet(e.getValue().iterator())))); }
AsyncTaskWorker(TaskInstance task) { this.task = task; this.callbackManager = new TaskCallbackManager(this, callbackTimer, callbackTimeoutMs, maxConcurrency, clock); Set<SystemStreamPartition> sspSet = getWorkingSSPSet(task); this.state = new AsyncTaskState(task.taskName(), task.metrics(), sspSet, task.intermediateStreams().nonEmpty()); }
@Test public void testGetSerdeStreamsDoesNotExist() { StreamConfig config = buildConfig(buildProp(SYSTEM_STREAM_1, "samza.key1"), "value1", "key2", "value2"); assertTrue(config.getSerdeStreams(STREAM1_SYSTEM).isEmpty()); }
@Test public void testGetSerdeStreamsFromSystemStream() { StreamConfig config = buildConfig(buildProp(SYSTEM_STREAM_1, StreamConfig.KEY_SERDE()), "value1", buildProp(SYSTEM_STREAM_2, StreamConfig.MSG_SERDE()), "value2", "key3", "value3"); assertEquals(1, config.getSerdeStreams(STREAM1_SYSTEM).size()); assertEquals(1, config.getSerdeStreams(STREAM2_SYSTEM).size()); assertEquals("value1", config.getStreamKeySerde(SYSTEM_STREAM_1).get()); assertEquals("value2", config.getStreamMsgSerde(SYSTEM_STREAM_2).get()); }
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e -> e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() == 0) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "no valid endpoints available. %s", serverEndpoints )); } else if (possibleEndpoints.size() == 1) { return possibleEndpoints.head(); } else { // TODO: the decision on which HTTP/2 endpoint to use should be based on config (e.g. maybe the user set // `akka.grpc.client."".use-tls` to false for gRPC so this should return the non-TLS HTTP/2 endpoint on the list. return possibleEndpoints.filter(endpoint -> endpoint.ssl().isDefined()).head(); } }
private void addExistingAclsForResource(java.util.Map<Resource, scala.collection.immutable.Set<Acl>> resourceAclsMap, Resource resource, java.util.Set<Acl> newAclsJava) { final scala.collection.immutable.Set<Acl> existingAcls = resourceAclsMap.get(resource); if (existingAcls != null) { final Iterator<Acl> aclsIter = existingAcls.iterator(); while (aclsIter.hasNext()) { Acl curAcl = aclsIter.next(); newAclsJava.add(curAcl); } } }
AsyncTaskWorker(TaskInstance task) { this.task = task; this.callbackManager = new TaskCallbackManager(this, callbackTimer, callbackTimeoutMs, maxConcurrency, clock); Set<SystemStreamPartition> sspSet = getWorkingSSPSet(task); this.state = new AsyncTaskState(task.taskName(), task.metrics(), sspSet, task.intermediateStreams().nonEmpty()); }
@Test public void testGetSerdeStreamsFromStreamId() { StreamConfig config = buildConfig( buildProp(STREAM1_STREAM_ID, StreamConfig.SYSTEM()), STREAM1_SYSTEM, buildProp(STREAM1_STREAM_ID, StreamConfig.PHYSICAL_NAME()), STREAM1_PHYSICAL_NAME, buildProp(STREAM1_STREAM_ID, StreamConfig.KEY_SERDE()), "value1", buildProp(STREAM2_STREAM_ID, StreamConfig.SYSTEM()), STREAM2_SYSTEM, buildProp(STREAM2_STREAM_ID, StreamConfig.PHYSICAL_NAME()), STREAM2_PHYSICAL_NAME, buildProp(STREAM2_STREAM_ID, StreamConfig.MSG_SERDE()), "value2", "key3", "value3"); assertEquals(1, config.getSerdeStreams(STREAM1_SYSTEM).size()); assertEquals(1, config.getSerdeStreams(STREAM2_SYSTEM).size()); assertEquals("value1", config.getStreamKeySerde(SYSTEM_STREAM_1).get()); assertEquals("value2", config.getStreamMsgSerde(SYSTEM_STREAM_2).get()); }
if (SwaggerSpec.containerTypes().contains(elementsProperty.type())) { LOGGER.debug("Cannot include nested collection schema in swagger docs: {}", schema); return null;
@VisibleForTesting static MemberName memberToName(final Member member) { return MemberName.forName(member.roles().iterator().next()); }
AsyncTaskWorker(TaskInstance task) { this.task = task; this.callbackManager = new TaskCallbackManager(this, callbackTimer, callbackTimeoutMs, maxConcurrency, clock); Set<SystemStreamPartition> sspSet = getWorkingSSPSet(task); this.state = new AsyncTaskState(task.taskName(), task.metrics(), sspSet, task.intermediateStreams().nonEmpty()); }
scala.collection.Iterator<Address> endpointAddressesIterator = endpointAddresses.toIterator(); HashSet<ServiceInstance> serviceInstances = new HashSet<ServiceInstance>(); while (endpointAddressesIterator.hasNext()) {
@Test public void testGetSerdeStreamsFromSystemStreamAndStreamId() { StreamConfig config = buildConfig(buildProp(SYSTEM_STREAM_1, StreamConfig.KEY_SERDE()), "value1", buildProp(STREAM1_STREAM_ID, StreamConfig.SYSTEM()), STREAM1_SYSTEM, buildProp(STREAM1_STREAM_ID, StreamConfig.PHYSICAL_NAME()), STREAM1_PHYSICAL_NAME, buildProp(STREAM1_STREAM_ID, StreamConfig.KEY_SERDE()), "value1OVERRIDE", buildProp(STREAM2_STREAM_ID, StreamConfig.SYSTEM()), STREAM2_SYSTEM, buildProp(STREAM2_STREAM_ID, StreamConfig.PHYSICAL_NAME()), STREAM2_PHYSICAL_NAME, buildProp(STREAM2_STREAM_ID, StreamConfig.MSG_SERDE()), "value2", "key3", "value3"); assertEquals(1, config.getSerdeStreams(STREAM1_SYSTEM).size()); assertEquals(1, config.getSerdeStreams(STREAM2_SYSTEM).size()); assertEquals("value1OVERRIDE", config.getStreamKeySerde(SYSTEM_STREAM_1).get()); assertEquals("value2", config.getStreamMsgSerde(SYSTEM_STREAM_2).get()); }
/** * Returns all {@link Acl}s associated to the given {@link Resource} * * @param resource * the {@link Resource} to look up {@link Acl}s for * @return unmodifiable set of all {@link Acl}s associated to the given {@link Resource} * @throws IllegalArgumentException * if resource is {@code null} * @throws AdminOperationException * if there is an issue reading the {@link Acl}s */ public Set<Acl> getAcls(Resource resource) { if (resource == null) throw new IllegalArgumentException("resource cannot be null"); LOG.debug("Fetching all ACLs for resource [{}]", resource); try { return Collections.unmodifiableSet(convertToJavaSet(getAuthorizer().getAcls(resource).iterator())); } catch (ZkException e) { throw new AdminOperationException("Unable to retrieve ACLs for resource: " + resource, e); } }
AsyncTaskWorker(TaskInstance task) { this.task = task; this.callbackManager = new TaskCallbackManager(this, callbackTimer, callbackTimeoutMs, maxConcurrency, clock); Set<SystemStreamPartition> sspSet = getWorkingSSPSet(task); this.state = new AsyncTaskState(task.taskName(), task.metrics(), sspSet, task.intermediateStreams().nonEmpty()); }
scala.collection.Iterator<Address> endpointAddressesIterator = endpointAddresses.toIterator(); HashSet<ServiceInstance> serviceInstances = new HashSet<ServiceInstance>(); while (endpointAddressesIterator.hasNext()) {
assertEquals(0, config.getSerdeStreams(STREAM1_SYSTEM).size()); assertEquals("value1", new SystemConfig(config).getSystemKeySerde(STREAM1_SYSTEM).get()); assertEquals("newest", config.getDefaultStreamOffset(SYSTEM_STREAM_1).get());
private void verifyAcls(scala.collection.immutable.Set<Acl> acls) { final Iterator<Acl> iterator = acls.iterator(); while (iterator.hasNext()) { final Acl acl = iterator.next(); assert acl.principal().getPrincipalType().toLowerCase().equals("role") : "Only Acls with KafkaPrincipal of type \"role;\" is supported."; assert acl.permissionType().name().equals(Allow.name()) : "Only Acls with Permission of type \"Allow\" is supported."; } }