All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.logspace.jvm.agent.api.order.AgentControllerOrder Maven / Gradle / Ivy

The newest version!
/**
 * Logspace
 * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
 * This program and the accompanying materials are made available under the terms of
 * the Eclipse Public License Version 1.0, which accompanies this distribution and
 * is available at http://www.eclipse.org/legal/epl-v10.html.
 */
package io.logspace.jvm.agent.api.order;

import java.util.ArrayList;
import java.util.List;

/**
 * The {@link AgentControllerOrder} contains configuration parameters for controlling the commit behavior of an
 * {@link io.logspace.jvm.agent.api.AgentController AgentController} as well as the {@link AgentOrder orders} for the individual
 * {@link io.logspace.jvm.agent.api.Agent Agents} registered with the controller.
 */
public class AgentControllerOrder {

    public static final String FIELD_COMMIT_MAX_COUNT = "commit-max-count";
    public static final String FIELD_COMMIT_MAX_SECONDS = "commit-max-seconds";
    public static final String FIELD_AGENT_ORDERS = "agent-orders";
    public static final String FIELD_ID = "id";
    public static final String FIELD_TRIGGER_TYPE = "trigger-type";
    public static final String FIELD_TRIGGER_PARAMETER = "trigger-parameter";

    /**
     * The individual {@link AgentOrder AgentOrders} in this {@link AgentControllerOrder}
     */
    private List agentOrders = new ArrayList();

    /**
     * The maximum amount of time after which collected {@link io.logspace.jvm.agent.api.event.Event Events} should be committed.
     */
    private Integer commitMaxSeconds;

    /**
     * Adds the given agentOrder to this {@link AgentControllerOrder}.
*
* This method will not remove an already existing order for the same {@link io.logspace.jvm.agent.api.Agent Agent}. * * @param agentOrder The {@link AgentOrder} to add. */ public void add(AgentOrder agentOrder) { this.agentOrders.add(agentOrder); } /** * Retrieves an {@link AgentOrder} for the given agentId if this {@link AgentControllerOrder} contains such an order. * * @param agentId The ID of the {@link io.logspace.jvm.agent.api.Agent} to find a matching AgentOrder for. * @return The first AgentOrder that matches the given id or null if no such AgentOrder exists. */ public AgentOrder getAgentOrder(String agentId) { for (AgentOrder eachAgentOrder : this.agentOrders) { if (eachAgentOrder.getId().equals(agentId)) { return eachAgentOrder; } } return null; } public List getAgentOrders() { return this.agentOrders; } /** * @return The number of {@link AgentOrder} in this {@link AgentControllerOrder}. */ public int getAgentOrdersCount() { if (this.agentOrders == null) { return 0; } return this.agentOrders.size(); } public Integer getCommitMaxSeconds() { return this.commitMaxSeconds; } /** * @return true if this {@link AgentControllerOrder} contains at least one {@link AgentOrder}. */ public boolean hasAgentOrders() { return this.agentOrders != null && !this.agentOrders.isEmpty(); } public void setAgentOrders(List agentOrders) { this.agentOrders = agentOrders; } public void setCommitMaxSeconds(Integer commitMaxSeconds) { this.commitMaxSeconds = commitMaxSeconds; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy