当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationException类代码示例

本文整理汇总了Java中com.newrelic.metrics.publish.configuration.ConfigurationException的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationException类的具体用法?Java ConfigurationException怎么用?Java ConfigurationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurationException类属于com.newrelic.metrics.publish.configuration包,在下文中一共展示了ConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createConfiguredAgents

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
void createConfiguredAgents(Runner runner) throws ConfigurationException {
    if (Config.getValue("agents") != null) {
        if ( !(Config.getValue("agents") instanceof JSONArray) ) {
            throw new ConfigurationException("Plugin 'agents' JSON configuration must be an array");
        }
        
        JSONArray json = Config.getValue("agents");
        for (int i = 0; i < json.size(); i++) {
            JSONObject obj = (JSONObject) json.get(i);
            @SuppressWarnings("unchecked")
            Map<String, Object> map = obj;
            createAndRegister(runner, map);
        }
    } else {
        createAndRegister(runner, new HashMap<String, Object>());
    }
}
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:18,代码来源:AgentFactory.java

示例2: readJSONFile

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * Read in JSON file from the provided filename.
 * Now deprecated and will be removed in a future release.
 * <p>
 * See {@link Config#getValue(String)} for using the new {@code plugin.json} configuration file.
 * @param filename the filename to read in
 * @return JSONArray the JSONArray that represents the JSON file
 * @throws ConfigurationException if an error occurs reading in or parsing the JSON file
 */
@Deprecated
public JSONArray readJSONFile(String filename) throws ConfigurationException {
    Object parseResult = null;

    File file = getConfigurationFile(filename);

    try {
        FileReader reader = new FileReader(file);
        JSONParser parser = new JSONParser();

        try {
            parseResult = parser.parse(reader);
        } catch (ParseException e) {
            throw logAndThrow("Error parsing config file " + file.getAbsolutePath());
        }
    } catch(IOException ioEx) {
        throw logAndThrow("Error reading config file " + file.getAbsolutePath());
    }
    
    JSONArray json = (JSONArray) parseResult;
    return json;
}
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:32,代码来源:AgentFactory.java

示例3: Runner

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * Constructs a {@code Runner}
 * @throws ConfigurationException if there is a configuration issue
 */
public Runner() throws ConfigurationException {
    super();
    componentAgents = new LinkedList<Agent>();

    try {
        Config.init();
        Logger.init(Config.getValue("log_level", "info"),
                    Config.getValue("log_file_path", "logs"),
                    Config.getValue("log_file_name", "newrelic_plugin.log"),
                    getLogLimitInKilobytes());
        logger = Logger.getLogger(Runner.class);
        config = new SDKConfiguration();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
}
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:21,代码来源:Runner.java

示例4: createConfiguredAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
@Override
  public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {

String agentName = (String) properties.get("agentName");
String reportMetricsToServers = (String) properties.get("reportMetricsToServers");
if (agentName == null)
{
          throw new ConfigurationException("'agentName' in plugin.json file cannot be null.");
}
if (reportMetricsToServers == null)
{
	throw new ConfigurationException("'reportMetricsToServers' in plugin.json file cannot be null");
}
if (Boolean.valueOf(reportMetricsToServers) == null)
{
	throw new ConfigurationException("'reportMetricsToServers' must have the value 'true' or 'false', not " + reportMetricsToServers);
}

      JSONArray scripts = (JSONArray)properties.get("scriptsToExecute");

      return new ScriptAgent(agentName, scriptsToExecute(scripts), Boolean.valueOf(reportMetricsToServers));
  }
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:23,代码来源:ScriptAgentFactory.java

示例5: buildSshCommand

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
private String buildSshCommand(Map<String, Object> properties) throws ConfigurationException {
    String sshCommand = "";

    String user = (String) properties.get("user");
    String host = (String) properties.get("host");
    if (!properties.containsKey("user")) {
        throw new ConfigurationException("This agent is configured to connect via ssh using host '" + host + "', but no user is given. Please check your 'config/plugin.json' file.");
    }
    if (!properties.containsKey("host")) {
        throw new ConfigurationException("This agent is configured to connect via ssh using user '" + user + "', but no host is given. Please check your 'config/plugin.json' file.");
    }

    sshCommand += "ssh -t " + user + "@" + host;

    if (properties.containsKey("identity")) {
        sshCommand += " -i " + properties.get("identity");
    }
    if (properties.containsKey("port")) {
        sshCommand += " -p " + properties.get("port");
    }
    if (properties.containsKey("options")) {
        sshCommand += " " + properties.get("options");
    }

    return sshCommand;
}
 
开发者ID:Bauer-Xcel-Media,项目名称:newrelic_varnish_plugin,代码行数:27,代码来源:VarnishAgentFactory.java

示例6: createConfiguredAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> map) throws ConfigurationException {
    String name = (String) map.get(NAME);
    String host = (String) map.get(HOST);
    String port = (String) map.get(PORT);
    String username = isNullOrEmpty(map.get(USERNAME)) ? null : (String)map.get(USERNAME);
    String password = isNullOrEmpty(map.get(PASSWORD)) ? null : (String)map.get(PASSWORD);

    if (name == null || host == null || port == null) {
        throw new ConfigurationException(String.format("'%s', '%s' and '%s' cannot be null.", USERNAME, PASSWORD, PORT));
    }

    String[] hostsRaw = host.split(",");
    List<String> hosts = new ArrayList<>();
    for(String hostRaw : hostsRaw) {
        hosts.add(hostRaw.trim());
    }

    return new CassandraAgent(new JMXRunnerFactory(), name, hosts, port, username, password);
}
 
开发者ID:thoersch,项目名称:new-relic-cassandra,代码行数:21,代码来源:CassandraAgentFactory.java

示例7: getConfigurationFile

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
private File getConfigurationFile(String configFileName) throws ConfigurationException {
    String path = Config.getConfigDirectory() + File.separatorChar + configFileName;
    File file = new File(path);
    if (!file.exists()) {
        throw logAndThrow("Cannot find config file " + path);
    }
    return file;
}
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:9,代码来源:AgentFactory.java

示例8: setupAgents

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
private void setupAgents() throws ConfigurationException {
    logger.debug("Setting up agents to be run");

    createAgents();
    if(config.internalGetServiceURI() != null) {
        logger.info("Metric service URI: ", config.internalGetServiceURI());
    }

    context = new Context();

    Iterator<Agent> iterator = componentAgents.iterator();
    while (iterator.hasNext()) {
        Agent agent = iterator.next();

        setupAgentContext(agent);

        agent.prepareToRun();
        agent.setupMetrics();

        //TODO this is a really awkward place to set the license key on the request
        context.licenseKey = config.getLicenseKey();
        if(config.internalGetServiceURI() != null) {
            context.internalSetServiceURI(config.internalGetServiceURI());
        }
        context.internalSetSSLHostVerification(config.isSSLHostVerificationEnabled());
    }
}
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:28,代码来源:Runner.java

示例9: main

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
/**
* Starts up the agent.
* @param args Command line arguments (no used)
*/
  public static void main(String[] args) {
      try {
          Runner runner = new Runner();
          runner.add(new ScriptAgentFactory());
          runner.setupAndRun(); // Never returns
      } catch (ConfigurationException e) {
          System.err.println("ERROR: " + e.getMessage());
          System.exit(-1);
      }
  }
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:15,代码来源:Main.java

示例10: createConfiguredAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> pluginProperties) throws ConfigurationException {
    AgentProperties properties = AgentProperties.parse(pluginProperties);
    logger.info("Creating agent using: ", properties);

    DropwizardAgent agent = new DropwizardAgent(properties.getName());
    registerProbes(properties, agent);
    return agent;
}
 
开发者ID:dbaggott,项目名称:newrelic-dropwizard,代码行数:10,代码来源:DropwizardAgentFactory.java

示例11: main

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        Runner runner = new Runner();
        DropwizardAgentFactory agentFactory = new DropwizardAgentFactory();
        runner.add(agentFactory);
        runner.setupAndRun(); // Never returns
    } catch (ConfigurationException e) {
        System.err.println("ERROR: " + e.getMessage());
        System.exit(-1);
    }
}
 
开发者ID:dbaggott,项目名称:newrelic-dropwizard,代码行数:12,代码来源:Main.java

示例12: createConfiguredAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
    String name = (String) properties.get("name");
    String statusUrl = (String) properties.get("status_url");

    if (name == null || statusUrl == null) {
        throw new ConfigurationException("'name' and 'status_url' cannot be null. Do you have a 'config/plugin.json' file?");
    }

    return new NginxAgent(name, statusUrl);
}
 
开发者ID:rchouinard,项目名称:newrelic-nginx-plugin,代码行数:12,代码来源:NginxAgentFactory.java

示例13: main

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        Runner runner = new Runner();
        runner.add(new NginxAgentFactory());
        runner.setupAndRun(); // Never returns
    } catch (ConfigurationException e) {
        System.err.println("ERROR: " + e.getMessage());
        System.exit(-1);
    }
}
 
开发者ID:rchouinard,项目名称:newrelic-nginx-plugin,代码行数:11,代码来源:Main.java

示例14: NginxAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
public NginxAgent(String name, String statusUrl) throws ConfigurationException {
    super(GUID, VERSION);
    try {
        this.name = name;
        this.url = new URL(statusUrl);
        this.connectionsAccepted = new EpochCounter();
        this.connectionsDropped  = new EpochCounter();
        this.requestsTotal       = new EpochCounter();
    } catch (MalformedURLException e) {
        throw new ConfigurationException("Status URL could not be parsed", e);
    }
}
 
开发者ID:rchouinard,项目名称:newrelic-nginx-plugin,代码行数:13,代码来源:NginxAgent.java

示例15: VarnishAgent

import com.newrelic.metrics.publish.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * Constructor.
 */
public VarnishAgent(String name, VarnishStats stats, Map<String, MetricMeta> meta, Map<String, String> labels) throws ConfigurationException {
    super(GUID, VERSION);

    this.name = name;
    this.stats = stats;
    this.meta = meta;
    this.labels = labels;
}
 
开发者ID:Bauer-Xcel-Media,项目名称:newrelic_varnish_plugin,代码行数:12,代码来源:VarnishAgent.java


注:本文中的com.newrelic.metrics.publish.configuration.ConfigurationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。