Java Code Examples for akka.actor.ActorSystem#Settings

The following examples show how to use akka.actor.ActorSystem#Settings . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJsonifiableWithDittoHeadersSerializer.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructs a new {@code AbstractJsonifiableWithDittoHeadersSerializer} object.
 *
 * @param identifier a unique identifier identifying the serializer.
 * @param actorSystem the ExtendedActorSystem to use in order to dynamically load mapping strategies.
 * @param manifestProvider a function for retrieving string manifest information from arbitrary to map objects.
 * @param serializerName a name to be used for this serializer when reporting metrics, in the log and in error
 * messages.
 */
protected AbstractJsonifiableWithDittoHeadersSerializer(final int identifier, final ExtendedActorSystem actorSystem,
        final Function<Object, String> manifestProvider, final String serializerName) {

    this.identifier = identifier;
    this.serializerName = serializerName;

    mappingStrategies = MappingStrategies.loadMappingStrategies(actorSystem);
    this.manifestProvider = checkNotNull(manifestProvider, "manifestProvider");

    final ActorSystem.Settings settings = actorSystem.settings();
    final Config config = settings.config();
    defaultBufferSize = config.withFallback(FALLBACK_CONF).getBytes(CONFIG_DIRECT_BUFFER_SIZE);
    final int maxPoolEntries = config.withFallback(FALLBACK_CONF).getInt(CONFIG_DIRECT_BUFFER_POOL_LIMIT);
    byteBufferPool = new DirectByteBufferPool(defaultBufferSize.intValue(), maxPoolEntries);

    inCounter = DittoMetrics.counter(serializerName.toLowerCase() + METRIC_NAME_SUFFIX)
            .tag(METRIC_DIRECTION, "in");
    outCounter = DittoMetrics.counter(serializerName.toLowerCase() + METRIC_NAME_SUFFIX)
            .tag(METRIC_DIRECTION, "out");
}
 
Example 2
Source File: MappingStrategies.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Loads the MappingStrategies in the passed ActorSystem this is running in by looking up the config key
 * {@value CONFIG_KEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION}.
 *
 * @param actorSystem the ActorSystem we are running in.
 * @return the resolved MappingStrategy.
 */
public static MappingStrategies loadMappingStrategies(final ActorSystem actorSystem) {

    // Load via config the class implementing MappingStrategies:
    final ActorSystem.Settings settings = actorSystem.settings();
    final Config config = settings.config();
    final String mappingStrategyClass = config.getString(CONFIG_KEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION);

    return AkkaClassLoader.instantiate(actorSystem, MappingStrategies.class, mappingStrategyClass);
}
 
Example 3
Source File: ThingPersistenceActorMailbox.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new {@code ThingBoundedMailbox}. This constructor signature must exist, it will be called by Akka.
 *
 * @param settings the ActorSystem settings.
 * @param config the config.
 */
public ThingPersistenceActorMailbox(final ActorSystem.Settings settings, final Config config) {
    // put your initialization code here
    capacity = config.getInt("mailbox-capacity");
    if (capacity < 1) {
        throw new IllegalArgumentException("Mailbox capacity must not be less than 1");
    }
}
 
Example 4
Source File: PolicyPersistenceActorMailbox.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new {@code PolicyBoundedMailbox}.
 * This constructor signature must exist, it will be called by Akka.
 *
 * @param settings the ActorSystem settings.
 * @param config the config.
 */
public PolicyPersistenceActorMailbox(final ActorSystem.Settings settings, final Config config) {
    // put your initialization code here
    capacity = config.getInt("mailbox-capacity");
    if (capacity < 1) {
        throw new IllegalArgumentException("Mailbox capacity must not be less than 1");
    }
}
 
Example 5
Source File: FlowerBoundedMailbox.java    From flower with Apache License 2.0 4 votes vote down vote up
public FlowerBoundedMailbox(ActorSystem.Settings settings, Config config) {
  this(config.getInt("mailbox-capacity"), config.getDuration("mailbox-push-timeout-time"));
}
 
Example 6
Source File: FlowerUnboundedMailbox.java    From flower with Apache License 2.0 votes vote down vote up
public FlowerUnboundedMailbox(ActorSystem.Settings settings, Config config) {}