Tabnine Logo
Signal
Code IndexAdd Tabnine to your IDE (free)

How to use
Signal
in
org.eclipse.ditto.signals.base

Best Java code snippets using org.eclipse.ditto.signals.base.Signal (Showing top 20 results out of 315)

origin: eclipse/ditto

private BiConsumer<Void, Throwable> handleEnforcementCompletion(final T signal, final ActorRef sender) {
  return (_void, throwable) -> {
    if (throwable != null) {
      final Throwable error = throwable instanceof CompletionException
          ? throwable.getCause()
          : throwable;
      reportError("Error thrown during enforcement", sender, error, signal.getDittoHeaders());
    }
  };
}
origin: eclipse/ditto

  private static ShardedMessageEnvelope createEnvelope(final EntityId entityId, final Signal<?> signal) {
    return ShardedMessageEnvelope.of(
        entityId.toString(),
        signal.getType(),
        signal.toJson(signal.getImplementedSchemaVersion(), FieldType.regularOrSpecial()),
        signal.getDittoHeaders());
  }
}
origin: eclipse/ditto

  @Override
  public void accept(final ExternalMessage externalMessage, final Signal<?> signal) {
    externalMessage.getEnforcementFilter().ifPresent(enforcementFilter -> {
      log.debug("Connection Signal ID Enforcement enabled - matching Signal ID <{}> with filter: {}",
          signal.getId(), enforcementFilter);
      enforcementFilter.match(signal.getId(), signal.getDittoHeaders());
    });
  }
}
origin: eclipse/ditto

/**
 * Wrap a signal in a sharded message envelope addressed to the correct {@code EnforcerActor}.
 *
 * @param signal the signal to wrap.
 * @return the sharded message envelope.
 */
public static ShardedMessageEnvelope wrapForEnforcer(final Signal<?> signal) {
  final EntityId entityId;
  if (MessageCommand.RESOURCE_TYPE.equals(signal.getResourceType())) {
    entityId = EntityId.of(ThingCommand.RESOURCE_TYPE, signal.getId());
  } else {
    entityId = EntityId.of(signal.getResourceType(), signal.getId());
  }
  return createEnvelope(entityId, signal);
}
origin: org.eclipse.ditto/ditto-services-connectivity-messaging

  return;
if (connectionId.equals(signal.getDittoHeaders().getOrigin().orElse(null))) {
  log.debug("Signal dropped: was sent by myself.");
  return;
    PlaceholderFilter.filterTargets(subscribedAndAuthorizedTargets, signal.getId(),
        unresolvedPlaceholder -> log.info(UNRESOLVED_PLACEHOLDERS_MESSAGE, unresolvedPlaceholder));
log.debug("Forwarding signal <{}> to client actor with targets: {}.", signal.getType(), filteredTargets);
origin: org.eclipse.ditto/ditto-signals-base

/**
 * Returns the name of the signal. This is gathered by the type of the signal by default.
 *
 * @return the name.
 */
@Override
default String getName() {
  return getType().contains(":") ? getType().split(":")[1] : getType();
}
origin: eclipse/ditto

/**
 * Extend a signal by read-subjects header given explicitly.
 *
 * @param <T> type of the signal.
 * @param signal the signal to extend.
 * @param readSubjects explicitly-given read subjects.
 * @return the extended signal.
 */
protected static <T extends Signal> T addReadSubjectsToSignal(final Signal<T> signal,
    final Set<String> readSubjects) {
  final DittoHeaders newHeaders = signal.getDittoHeaders()
      .toBuilder()
      .readSubjects(readSubjects)
      .build();
  return signal.setDittoHeaders(newHeaders);
}
origin: eclipse/ditto

private void handleSignal(final Signal<?> signal) {
  LogUtil.enhanceLogWithCorrelationId(logger, signal);
  final DittoHeaders dittoHeaders = signal.getDittoHeaders();
  if (connectionCorrelationId.equals(dittoHeaders.getOrigin().orElse(null))) {
    logger.debug("Got Signal <{}> in <{}> session, " +
        "but this was issued by this connection itself, not telling "
        + "eventAndResponsePublisher about it", signal.getType(), type);
  } else {
    // check if this session is "allowed" to receive the LiveSignal
    if (authorizationSubjects != null &&
        !Collections.disjoint(dittoHeaders.getReadSubjects(), authorizationSubjects)) {
      if (matchesNamespaces(signal)) {
        if (matchesFilter(signal)) {
          logger.debug("Got Signal <{}> in <{}> session, " +
                  "telling eventAndResponsePublisher about it: {}",
              signal.getType(), type, signal);
          eventAndResponsePublisher.tell(signal, getSelf());
        } else {
          logger.debug("Signal does not match filter");
        }
      } else {
        logger.debug("Signal does not match namespaces");
      }
    }
  }
}
origin: org.eclipse.ditto/ditto-protocol-adapter

@Override
public Adaptable toAdaptable(final Signal<?> signal) {
  final boolean isLive = isLiveSignal(signal);
  final TopicPath.Channel channel = isLive ? TopicPath.Channel.LIVE : TopicPath.Channel.TWIN;
  if (signal instanceof MessageCommand) {
    return toAdaptable((MessageCommand<?, ?>) signal);
  } else if (signal instanceof MessageCommandResponse) {
    return toAdaptable((MessageCommandResponse<?, ?>) signal);
  } else if (signal instanceof Command) {
    return toAdaptable((Command<?>) signal, channel);
  } else if (signal instanceof CommandResponse) {
    return toAdaptable((CommandResponse<?>) signal, channel);
  } else if (signal instanceof Event) {
    return toAdaptable((Event<?>) signal, channel);
  }
  throw UnknownSignalException.newBuilder(signal.getName()).dittoHeaders(signal.getDittoHeaders()).build();
}
origin: eclipse/ditto

final String signalId = transformedSignal.getId();
final String signalType = transformedSignal.getType();
if (signalId.isEmpty()) {
  log.info("Sending signal without ID and type <{}> to concierge-dispatcherActor", signalType);
origin: org.eclipse.ditto/ditto-services-connectivity-messaging

PlaceholderFilter.apply(e.getValue(), sourceSignal.getId(), THING_PLACEHOLDER, true))
origin: eclipse/ditto

  return;
if (connectionId.equals(signal.getDittoHeaders().getOrigin().orElse(null))) {
  log.debug("Signal dropped: was sent by myself.");
  return;
    PlaceholderFilter.filterTargets(subscribedAndAuthorizedTargets, signal.getId(),
        unresolvedPlaceholder -> log.info(UNRESOLVED_PLACEHOLDERS_MESSAGE, unresolvedPlaceholder));
log.debug("Forwarding signal <{}> to client actor with targets: {}.", signal.getType(), filteredTargets);
origin: eclipse/ditto

/**
 * Returns the name of the signal. This is gathered by the type of the signal by default.
 *
 * @return the name.
 */
@Override
default String getName() {
  return getType().contains(":") ? getType().split(":")[1] : getType();
}
origin: org.eclipse.ditto/ditto-protocol-adapter

private Signal<?> fromLiveAdaptable(final Adaptable adaptable) {
  final TopicPath topicPath = adaptable.getTopicPath();
  final Signal<?> liveSignal;
  if (TopicPath.Criterion.MESSAGES.equals(topicPath.getCriterion())) { // /things/live/messages
    final boolean isResponse = adaptable.getPayload().getStatus().isPresent();
    if (isResponse) {
      liveSignal = messageCommandResponseAdapter.fromAdaptable(adaptable);
    } else {
      liveSignal = messageCommandAdapter.fromAdaptable(adaptable);
    }
  } else {
    liveSignal = signalFromAdaptable(adaptable, topicPath); // /things/live/(commands|events)
  }
  if (liveSignal != null) {
    final DittoHeadersBuilder enhancedHeadersBuilder = liveSignal.getDittoHeaders()
        .toBuilder()
        .channel(TopicPath.Channel.LIVE.getName());
    return liveSignal.setDittoHeaders(enhancedHeadersBuilder.build());
  } else {
    throw UnknownTopicPathException.newBuilder(topicPath).build();
  }
}
origin: eclipse/ditto

.match(ActorSubscriberMessage.OnNext.class, on -> on.element() instanceof Signal, onNext -> {
  final Signal<?> signal = (Signal) onNext.element();
  final Optional<String> correlationIdOpt = signal.getDittoHeaders().getCorrelationId();
  if (correlationIdOpt.isPresent()) {
    final String correlationId = correlationIdOpt.get();
    logger.debug("Got new Signal <{}>, currently outstanding are <{}>", signal.getType(),
        outstandingCommandCorrelationIds.size());
    delegateActor.tell(signal, getSelf());
  } else {
    logger.warning("Got a Signal <{}> without correlationId, NOT accepting/forwarding it: {}",
        signal.getType(), signal);
origin: eclipse/ditto

@Override
public Adaptable toAdaptable(final Signal<?> signal) {
  final boolean isLive = isLiveSignal(signal);
  final TopicPath.Channel channel = isLive ? TopicPath.Channel.LIVE : TopicPath.Channel.TWIN;
  if (signal instanceof MessageCommand) {
    return toAdaptable((MessageCommand<?, ?>) signal);
  } else if (signal instanceof MessageCommandResponse) {
    return toAdaptable((MessageCommandResponse<?, ?>) signal);
  } else if (signal instanceof Command) {
    return toAdaptable((Command<?>) signal, channel);
  } else if (signal instanceof CommandResponse) {
    return toAdaptable((CommandResponse<?>) signal, channel);
  } else if (signal instanceof Event) {
    return toAdaptable((Event<?>) signal, channel);
  }
  throw UnknownSignalException.newBuilder(signal.getName()).dittoHeaders(signal.getDittoHeaders()).build();
}
origin: eclipse/ditto

PlaceholderFilter.apply(e.getValue(), sourceSignal.getId(), THING_PLACEHOLDER, true))
origin: eclipse/ditto

private boolean isResponseExpected(final Signal<?> signal) {
  return signal instanceof Command && signal.getDittoHeaders().isResponseRequired();
}
origin: eclipse/ditto

final String correlationId = signal.getDittoHeaders().getCorrelationId().get();
if (signal instanceof SendClaimMessage) {
  if (signal.getDittoHeaders().isResponseRequired()) {
    responseReceivers.put(correlationId, sender);
  } else {
    log(signal).warning("No outstanding responses receiver for CommandResponse <{}>",
        signal.getType());
    if (wasPublished && signal.getDittoHeaders().isResponseRequired()) {
      responseReceivers.put(correlationId, sender);
      publishToMediator(withReadSubjects, StreamingType.LIVE_COMMANDS.getDistributedPubSubTopic(),
          sender);
      if (signal.getDittoHeaders().isResponseRequired()) {
        responseReceivers.put(correlationId, sender);
      signal.getDittoHeaders().getAuthorizationContext(),
      WRITE);
  if (authorized) {
    final EventSendNotAllowedException eventSendNotAllowedException =
        EventSendNotAllowedException.newBuilder(((ThingEvent) signal).getThingId())
            .dittoHeaders(signal.getDittoHeaders())
            .build();
    log(signal).info("Live Event was NOT authorized: <{}>", signal);
        " looked up! Answering with ThingNotAccessibleException.", signal.getType(),
origin: org.eclipse.ditto/ditto-services-utils-tracing

/**
 * Prepares an {@link ExpiringTimerBuilder} with default {@link #AMQP_ROUNDTRIP_METRIC_NAME} and tags.
 * @param command The command to extract tags.
 * @return The prepared {@link ExpiringTimerBuilder}
 */
public static ExpiringTimerBuilder newAmqpRoundTripTimer(final Signal<?> command) {
  if (command instanceof Command) {
    return newAmqpRoundTripTimer((Command) command);
  }
  final String metricsUri = AMQP_ROUNDTRIP_METRIC_NAME + command.getType();
  return newExpiringTimer(metricsUri)
      .tag(TracingTags.COMMAND_TYPE, command.getType());
}
org.eclipse.ditto.signals.baseSignal

Javadoc

A service message that incites to action or conveys notice or warning.

Most used methods

  • getDittoHeaders
  • getType
  • getId
  • setDittoHeaders
  • getImplementedSchemaVersion
  • getName
    Returns the name of the signal. This is gathered by the type of the signal by default.
  • getResourcePath
  • getResourceType
  • toJson

Popular in Java

  • Start an intent from android
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now