Search in sources :

Example 6 with JoynrHttpException

use of io.joynr.communications.exceptions.JoynrHttpException in project joynr by bmwcarit.

the class LongPollingMessagingDelegate method openChannel.

/*
     * Opens a channel for long polling.
     *
     * @param ccid
     *            the ID of the channel
     * @param atmosphereTrackingId
     *            the tracking ID
     * @return
     * @throws JoynrHttpException
     *             if no channel with the given ID was found (e.g. because it
     *             wasn't created before) or if the tracking ID wasn't set
     */
public Broadcastable openChannel(String ccid, String atmosphereTrackingId) {
    throwExceptionIfTrackingIdnotSet(atmosphereTrackingId);
    log.debug("GET Channels open long poll channelId: {} trackingId: {}", ccid, atmosphereTrackingId);
    // NOTE: as of Atmosphere 0.8.5: even though the parameter is set
    // not to create the broadcaster if not
    // found, if the
    // broadcaster is found, but set to "destroyed" then it is recreated
    // TODO when is a broadcaster "destroyed" ???
    Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(BounceProxyBroadcaster.class, ccid, false);
    if (broadcaster == null) {
        log.error("no broadcaster registered for channel {}", ccid);
        // broadcaster not found for given ccid
        throw new JoynrHttpException(Status.BAD_REQUEST, JOYNRMESSAGINGERROR_CHANNELNOTFOUND);
    }
    // in the cache
    return new Broadcastable(broadcaster);
}
Also used : Broadcastable(org.atmosphere.jersey.Broadcastable) JoynrHttpException(io.joynr.communications.exceptions.JoynrHttpException) Broadcaster(org.atmosphere.cpr.Broadcaster)

Example 7 with JoynrHttpException

use of io.joynr.communications.exceptions.JoynrHttpException in project joynr by bmwcarit.

the class MonitoringServiceRestAdapter method reportPerformance.

/**
 * Refreshes the performance measures of a bounce proxy instance, e.g.
 * active long polls.
 *
 * @param bpId
 *            the identifier of the bounce proxy
 * @param performanceMap
 *            key-value pairs of performance measures
 * @return empty response
 */
@POST
@Path("/{bpid: ([A-Z,a-z,0-9,_,\\-]+)(\\.)([A-Z,a-z,0-9,_,\\-]+)}/performance")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })
public Response reportPerformance(@PathParam("bpid") String bpId, Map<String, Integer> performanceMap) {
    if (!monitoringService.isRegistered(bpId)) {
        throw new JoynrHttpException(Status.BAD_REQUEST, JoynrBounceProxyControlErrorCode.BOUNCEPROXY_UNKNOWN, "bounce proxy '" + bpId + "'");
    }
    PerformanceMeasures performanceMeasures = new PerformanceMeasures();
    performanceMeasures.addMeasures(performanceMap);
    monitoringService.updatePerformanceMeasures(bpId, performanceMeasures);
    return Response.noContent().build();
}
Also used : JoynrHttpException(io.joynr.communications.exceptions.JoynrHttpException) PerformanceMeasures(io.joynr.messaging.info.PerformanceMeasures) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

JoynrHttpException (io.joynr.communications.exceptions.JoynrHttpException)7 POST (javax.ws.rs.POST)4 Produces (javax.ws.rs.Produces)4 EncodingException (io.joynr.smrf.EncodingException)3 UnsuppportedVersionException (io.joynr.smrf.UnsuppportedVersionException)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 ImmutableMessage (joynr.ImmutableMessage)3 Broadcaster (org.atmosphere.cpr.Broadcaster)3 URI (java.net.URI)2 Path (javax.ws.rs.Path)2 Channel (io.joynr.messaging.info.Channel)1 PerformanceMeasures (io.joynr.messaging.info.PerformanceMeasures)1 IOException (java.io.IOException)1 Consumes (javax.ws.rs.Consumes)1 UUIDBroadcasterCache (org.atmosphere.cache.UUIDBroadcasterCache)1 AtmosphereResource (org.atmosphere.cpr.AtmosphereResource)1 BroadcasterFactory (org.atmosphere.cpr.BroadcasterFactory)1 Broadcastable (org.atmosphere.jersey.Broadcastable)1