public void introspect(Channel channel) { channel.getBindings().forEach(b -> { if (b instanceof NATSBinding) { b.setConnectionTypes(Nats.class, Subscription.class); } }); } }
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 introspect(Channel channel) { if ("ring.buffer".equals(channel.getType())) { channel.setConnectionTypes(RingBuffer.class); } } }
protected RingBufferChannelBuilder(String name) { definition = new Channel(name); data = new RingBufferData(); definition.setMetadata(data); }
public void instantiateChannels(Composite composite, LogicalCompositeComponent parent, InstantiationContext context) { for (Channel definition : composite.getChannels().values()) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); if (parent.getChannel(uri) != null) { DuplicateChannel error = new DuplicateChannel(uri, parent); context.addError(error); continue; } LogicalChannel channel = new LogicalChannel(uri, definition, parent); for (Binding binding : definition.getBindings()) { LogicalBinding<Binding> logicalBinding = new LogicalBinding<>(binding, channel); channel.addBinding(logicalBinding); } channel.setDeployable(composite.getName()); parent.addChannel(channel); } }
public void deploy(Channel channel) throws Fabric3Exception { Composite wrapper = createWrapperComposite(channel.getName()); wrapper.add(channel); domain.include(wrapper); }
@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; }
definition.setConnectionTypes(RingBuffer.class); definition.setMetadata(data);
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; }
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);
public void instantiateChannels(Composite composite, LogicalCompositeComponent parent, InstantiationContext context) { for (Channel definition : composite.getChannels().values()) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); if (parent.getChannel(uri) != null) { DuplicateChannel error = new DuplicateChannel(uri, parent); context.addError(error); continue; } LogicalChannel channel = new LogicalChannel(uri, definition, parent); for (Binding binding : definition.getBindings()) { LogicalBinding<Binding> logicalBinding = new LogicalBinding<>(binding, channel); channel.addBinding(logicalBinding); } channel.setDeployable(composite.getName()); parent.addChannel(channel); } }
public void deploy(Channel channel) throws Fabric3Exception { Composite wrapper = createWrapperComposite(channel.getName()); wrapper.add(channel); domain.include(wrapper); }
@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; }
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; }
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);
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; } }
private void setChannelName(LogicalBinding binding, ZeroMQMetadata metadata) { if (binding.getParent() instanceof LogicalChannel) { String channelName = ((LogicalChannel) binding.getParent()).getDefinition().getName(); metadata.setChannelName(channelName); } }
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; }