private boolean isDirect(LogicalInvocable invocable, Map<LogicalChannel, DeliveryType> channels) { boolean direct = false; if (!channels.isEmpty()) { LogicalChannel logicalChannel = channels.keySet().iterator().next(); ServiceContract contract = invocable.getServiceContract(); if (contract == null) { return false; } Class<?> interfaceClass = contract.getInterfaceClass(); if (logicalChannel.isBound()) { Binding binding = logicalChannel.getBinding().getDefinition(); if (!binding.getConnectionTypes().isEmpty()) { direct = binding.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } else { Channel channel = logicalChannel.getDefinition(); if (!channel.getConnectionTypes().isEmpty()) { direct = channel.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } } return direct; }
private boolean isDirect(LogicalInvocable invocable, Map<LogicalChannel, DeliveryType> channels) { boolean direct = false; if (!channels.isEmpty()) { LogicalChannel logicalChannel = channels.keySet().iterator().next(); ServiceContract contract = invocable.getServiceContract(); if (contract == null) { return false; } Class<?> interfaceClass = contract.getInterfaceClass(); if (logicalChannel.isBound()) { Binding binding = logicalChannel.getBinding().getDefinition(); if (!binding.getConnectionTypes().isEmpty()) { direct = binding.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } else { Channel channel = logicalChannel.getDefinition(); if (!channel.getConnectionTypes().isEmpty()) { direct = channel.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } } return direct; }
public PhysicalChannelDefinition generate(LogicalChannel channel, QName deployable) throws GenerationException { URI uri = channel.getUri(); ChannelDefinition definition = channel.getDefinition(); String channelType = definition.getType(); boolean replicate = definition.getIntents().contains(ChannelConstants.REPLICATE_INTENT); PhysicalChannelDefinition physicalDefinition = new PhysicalChannelDefinition(uri, deployable, replicate, channelType, ASYNCHRONOUS_WORKER); physicalDefinition.setMetadata(definition.getMetadata().get(ChannelConstants.METADATA)); return physicalDefinition; }
private void setChannelName(LogicalBinding binding, ZeroMQMetadata metadata) { if (binding.getParent() instanceof LogicalChannel) { String channelName = ((LogicalChannel) binding.getParent()).getDefinition().getName(); metadata.setChannelName(channelName); } }
public PhysicalChannelDefinition generate(LogicalChannel channel, QName deployable) throws GenerationException { URI uri = channel.getUri(); ChannelDefinition definition = channel.getDefinition(); String channelType = definition.getType(); boolean replicate = definition.getIntents().contains(ChannelConstants.REPLICATE_INTENT); PhysicalChannelDefinition physicalDefinition = new PhysicalChannelDefinition(uri, deployable, replicate, channelType, ChannelDeliveryType.DEFAULT); physicalDefinition.setMetadata(definition.getMetadata().get(ChannelConstants.METADATA)); return physicalDefinition; } }
private void setChannelName(LogicalBinding binding, ZeroMQMetadata metadata) { if (binding.getParent() instanceof LogicalChannel) { String channelName = ((LogicalChannel) binding.getParent()).getDefinition().getName(); metadata.setChannelName(channelName); } }
/** * Aggregates intents of a binding by walking the implementation and structural hierarchies of the parent. * * @param binding the binding * @return the aggregated intents */ protected Set<QName> aggregateIntents(LogicalBinding<?> binding) throws PolicyResolutionException { Bindable parent = binding.getParent(); Set<QName> aggregatedIntents = new LinkedHashSet<>(); // add binding intents aggregatedIntents.addAll(binding.getIntents()); validateIntents(binding); if (parent instanceof LogicalReference) { return aggregateReferenceIntents((LogicalReference) parent, aggregatedIntents); } else if (parent instanceof LogicalService) { return aggregateServiceIntents((LogicalService) parent, aggregatedIntents); } else { // channel LogicalChannel channel = (LogicalChannel) parent; aggregatedIntents.addAll(channel.getDefinition().getIntents()); aggregatedIntents.addAll(channel.getIntents()); return aggregatedIntents; } }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel definition = channel.getDefinition(); String channelType = definition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, DeliveryType.DEFAULT, contributionUri); physicalChannel.setMetadata(definition.getMetadata(Object.class)); return physicalChannel; } }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel channelDefinition = channel.getDefinition(); String channelType = channelDefinition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, ASYNCHRONOUS_WORKER, contributionUri); physicalChannel.setMetadata(channelDefinition.getMetadata(Object.class)); return physicalChannel; }
@SuppressWarnings("unchecked") public PhysicalChannel generate(LogicalChannel channel, URI contributionUri, ChannelDirection direction) { String type = channel.getDefinition().getType(); ChannelGeneratorExtension generator = extensions.get(type); if (generator == null) { throw new Fabric3Exception("Channel generator not found: " + type); } PhysicalChannel physicalChannel = generator.generate(channel, contributionUri); if (!channel.getBindings().isEmpty()) { // generate binding information physicalChannel.setBound(true); physicalChannel.setChannelSide(ChannelDirection.CONSUMER == direction ? ChannelSide.CONSUMER : ChannelSide.PRODUCER); } else { physicalChannel.setChannelSide(ChannelSide.COLLOCATED); } return physicalChannel; }
@SuppressWarnings("unchecked") public PhysicalChannel generate(LogicalChannel channel, URI contributionUri, ChannelDirection direction) { String type = channel.getDefinition().getType(); ChannelGeneratorExtension generator = extensions.get(type); if (generator == null) { throw new Fabric3Exception("Channel generator not found: " + type); } PhysicalChannel physicalChannel = generator.generate(channel, contributionUri); if (!channel.getBindings().isEmpty()) { // generate binding information physicalChannel.setBound(true); physicalChannel.setChannelSide(ChannelDirection.CONSUMER == direction ? ChannelSide.CONSUMER : ChannelSide.PRODUCER); } else { physicalChannel.setChannelSide(ChannelSide.COLLOCATED); } return physicalChannel; }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel definition = channel.getDefinition(); String channelType = definition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, DeliveryType.DEFAULT, contributionUri); physicalChannel.setMetadata(definition.getMetadata(Object.class)); return physicalChannel; } }
public void bind(LogicalChannel channel) throws BindingSelectionException { ZeroMQMetadata metadata = createMetadata(); metadata.setChannelName(channel.getDefinition().getName()); ZeroMQBindingDefinition definition = new ZeroMQBindingDefinition("binding.zeromq", metadata); LogicalBinding<ZeroMQBindingDefinition> binding = new LogicalBinding<ZeroMQBindingDefinition>(definition, channel); channel.addBinding(binding); }
private PhysicalChannelConnectionDefinition generateProducerConnection(LogicalProducer producer, LogicalChannel channel, PhysicalConnectionSourceDefinition sourceDefinition, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { if (!channel.getZone().equals(producer.getParent().getZone()) && !channel.isBound()) { String name = channel.getDefinition().getName(); throw new GenerationException("Binding not configured on a channel where the producer is in a different zone: " + name); } PhysicalConnectionTargetDefinition targetDefinition = new ChannelTargetDefinition(channel.getUri(), ChannelSide.PRODUCER); targetDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }
if (channel.getDefinition() != null && !contributionUri.equals(channel.getDefinition().getContributionUri())) { continue; // composite is not part of the contribution being undeployed if (contributionUri.equals(channel.getDefinition().getContributionUri())) { channel.setState(MARKED);
if (channel.getDefinition() != null && !contributionUri.equals(channel.getDefinition().getContributionUri())) { continue; // composite is not part of the contribution being undeployed if (contributionUri.equals(channel.getDefinition().getContributionUri())) { channel.setState(MARKED);
@SuppressWarnings({"unchecked"}) private PhysicalChannelDefinition generateChannelDefinition(LogicalChannel channel, QName deployable, Direction direction) throws GenerationException { LogicalBinding<?> binding = channel.getBinding(); String type = channel.getDefinition().getType(); ChannelGenerator generator = channelGenerators.get(type); if (generator == null) { throw new GenerationException("Channel generator not found: " + type); } PhysicalChannelDefinition definition = generator.generate(channel, deployable); if (!channel.getBindings().isEmpty()) { // generate binding information if (!(binding.getDefinition() instanceof SCABinding)) { // avoid generating SCABinding ConnectionBindingGenerator bindingGenerator = getGenerator(binding); ChannelDeliveryType deliveryType = definition.getDeliveryType(); PhysicalChannelBindingDefinition bindingDefinition = bindingGenerator.generateChannelBinding(binding, deliveryType); definition.setBindingDefinition(bindingDefinition); definition.setChannelSide(Direction.CONSUMER == direction ? ChannelSide.CONSUMER : ChannelSide.PRODUCER); } else { definition.setChannelSide(ChannelSide.COLLOCATED); } } else { definition.setChannelSide(ChannelSide.COLLOCATED); } return definition; }
private PhysicalChannelConnectionDefinition generateConsumerConnection(LogicalConsumer consumer, LogicalChannel channel, PhysicalConnectionTargetDefinition targetDefinition, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { // the channel does not have bindings, which means it is a local channel if (!channel.getZone().equals(consumer.getParent().getZone()) && !channel.isBound()) { String name = channel.getDefinition().getName(); throw new GenerationException("Binding not configured on a channel where the consumer is in a different zone: " + name); } // construct a local connection to the channel PhysicalConnectionSourceDefinition sourceDefinition = new ChannelSourceDefinition(channel.getUri(), ChannelSide.CONSUMER); sourceDefinition.setSequence(consumer.getDefinition().getSequence()); sourceDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }