本文整理汇总了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>());
}
}
示例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;
}
示例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());
}
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}