@Override public MALEndpoint getEndpoint(final URI uri) throws IllegalArgumentException { String endpointUriPart = getRoutingPart(uri.getValue()); return endpointRoutingMap.get(endpointUriPart); }
/** * Check to see if a supplied URI would use the supplied Transport. * * @param dstUri The Uri. * @param transport The Transport to check. * @return Returns true if dstUri would create the same transport. */ public static boolean isSameTransport(final URI dstUri, final MALTransport transport) { init(); if ((null != dstUri) && (null != dstUri.getValue())) { return isSameTransport(dstUri.getValue(), transport); } return false; }
void registerPublishListener(final MessageDetails details, final MALPublishInteractionListener listener) { final StringPair id = new StringPair(details.uriFrom.getValue(), createProviderKey(details)); synchronized (publisherMap) { publisherMap.put(id, listener); MALContextFactoryImpl.LOGGER.log(Level.FINE, "Adding publisher: {0}", id); } }
MALPublishInteractionListener getPublishListenerAndRemove(final URI uri, final MessageDetails details) { final StringPair id = new StringPair(uri.getValue(), createProviderKey(details)); MALPublishInteractionListener list; synchronized (publisherMap) { list = publisherMap.remove(id); } if (null != list) { MALContextFactoryImpl.LOGGER.log(Level.FINE, "Removing publisher: {0}", id); } return list; }
private Address lookupAddress(final MALEndpoint callingEndpoint, final MALMessage msg) { final EndPointPair key = new EndPointPair(callingEndpoint.getURI().getValue(), msg); Address addr = providerEndpointMap.get(key); if (null == addr) { MALContextFactoryImpl.LOGGER.log(Level.WARNING, "lookupAddress failed to find local endpoint for {0}", new Object[] { key }); } return addr; }
MALPublishInteractionListener getPublishListener(final URI uri, final MALMessageHeader mshHdr) { final StringPair id = new StringPair(uri.getValue(), createProviderKey(mshHdr)); MALPublishInteractionListener list; synchronized (publisherMap) { list = publisherMap.get(id); } if (null != list) { MALContextFactoryImpl.LOGGER.log(Level.FINE, "Getting publisher: {0}", id); } return list; }
/** * Creates an instance of a Transport. * * @param dstUri The Uri. * @param properties QoS properties. * @return The transport handler. * @throws MALException on error. */ public static MALTransport instance(final URI dstUri, final Map properties) throws MALException { init(); if ((null != dstUri) && (null != dstUri.getValue())) { return internalInstance(dstUri.getValue(), properties); } return internalInstance(defaultProtocol, properties); }
private SubscriptionSource getConsumerEntry(final BrokerKey key, final MALMessageHeader hdr, final boolean create) { final Map<String, SubscriptionSource> rv = getConsumerMap(key); final String sig = hdr.getURIFrom().getValue(); SubscriptionSource ent = rv.get(sig); if ((null == ent) && (create)) { ent = createEntry(hdr); rv.put(sig, ent); } return ent; }
/** * Constructor. * * @param hdr The message header of the subscription message. * @param binding The broker binding that received the subscription. */ public SimpleSubscriptionSource(final MALMessageHeader hdr) { super(hdr, hdr.getURIFrom()); this.signature = hdr.getURIFrom().getValue(); }
private void handleConsumerCommunicationError(final BrokerKey key, final NotifyMessageSet notifyMessageSet) { final SubscriptionSource ent = getConsumerEntry(key, notifyMessageSet.details.uriTo.getValue()); if (null != ent) { ent.incCommsErrorCount(); if (ent.getCommsErrorCount() > 2) { MALBrokerImpl.LOGGER.log(Level.WARNING, "Removing to consumer due to too many comms errors : {0}", notifyMessageSet.details.uriTo.getValue()); // three strikes and you're out! internalDeregisterSubscriptions(key, ent, null); } } }
private PublisherSource getProviderEntry(final BrokerKey key, final MALMessageHeader hdr, final boolean create) { final Map<StringPair, PublisherSource> rv = getProviderMap(key); PublisherSource details = rv.get(new StringPair(hdr.getURIFrom().getValue(), createProviderKey(hdr))); if ((null == details) && create) { details = new PublisherSource(hdr.getURIFrom().getValue(), hdr.getQoSlevel()); rv.put(new StringPair(hdr.getURIFrom().getValue(), createProviderKey(hdr)), details); MALBrokerImpl.LOGGER.log(Level.FINE, "New publisher registering: {0}", hdr); } return details; }
/** * Checks if the archiveDetails structure contains a null value in any of * the following fields: network, timestamp or provider * * @param archiveDetails The archive details object to be checked. * @return The boolean value of the comparison */ public static Boolean archiveDetailsContainsNull(ArchiveDetails archiveDetails) { // Check if null return archiveDetails.getNetwork().getValue() == null || archiveDetails.getTimestamp() == null || archiveDetails.getProvider().getValue() == null; }
@Override public synchronized void handlePublishDeregister(final MALInteraction interaction) throws MALInteractionException, MALException { final MALMessageHeader hdr = interaction.getMessageHeader(); final BrokerKey key = new BrokerKey(hdr); report(key); final Map<StringPair, PublisherSource> rv = getProviderMap(key); if (null != rv.remove(new StringPair(hdr.getURIFrom().getValue(), createProviderKey(hdr)))) { MALBrokerImpl.LOGGER.log(Level.FINE, "Removing publisher details: {0}", hdr); } if (rv.isEmpty()) { providerMap.remove(key); } report(key); }
/** * Constructor. * @param hdr Source message. */ public BrokerKey(final MALMessageHeader hdr) { this.uri = hdr.getURITo().getValue(); this.session = hdr.getSession().getOrdinal(); this.sessionName = hdr.getSessionName().getValue(); }
@Override protected void thisObjectClose() throws MALException { super.thisObjectClose(); this.receiveHandler.deregisterProviderEndpoint(endpoint.getURI().getValue(), service); endpoint.stopMessageDelivery(); endpoint.close(); } }
/** * Constructor. * * @param hdr Source message. */ public AddressKey(final MALMessageHeader hdr) { this.uri = hdr.getURITo().getValue(); this.domain = hdr.getDomain(); this.networkZone = hdr.getNetworkZone().getValue(); this.session = hdr.getSession().getOrdinal(); this.sessionName = hdr.getSessionName().getValue(); }
public ArchivePersistenceObject(final ObjectType objectType, final IdentifierList domain, final Long objId, final ArchiveDetails archiveDetails, final Object object) { this.objectType = objectType; this.domainId = domain; this.objId = objId; this.providerURI = archiveDetails.getProvider().getValue(); this.network = archiveDetails.getNetwork().getValue(); this.timestampArchiveDetails = archiveDetails.getTimestamp().getValue(); this.sourceLink = archiveDetails.getDetails().getSource(); this.relatedLink = archiveDetails.getDetails().getRelated(); // this.obj = (Element) HelperAttributes.javaType2Attribute(object); this.object = object; }