summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-06-08 11:14:36 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2017-06-08 11:14:36 +0200
commit2b5100db52c300ce7b336da6dae2008baad57358 (patch)
treebd56fb339921d458b71f320317b03a2318df272f /config-model
parent739833c51230d2bdb7699906b7acaa6a8bb76044 (diff)
parentab131f2a48628dd7ed86e112819860c67e8df75b (diff)
Merge with master
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java60
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java5
-rwxr-xr-xconfig-model/src/main/perl/deploy25
3 files changed, 28 insertions, 62 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java b/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
index 9c761e425a7..fdb9fdf9796 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
@@ -11,6 +11,7 @@ import com.yahoo.vespa.config.buildergen.ConfigDefinition;
import com.yahoo.yolean.Exceptions;
import com.yahoo.vespa.config.*;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
@@ -46,13 +47,19 @@ class InstanceResolver {
* @param targetDef the def to use
* @return the config instance or null of no producer for this found in model
*/
+ @SuppressWarnings("unchecked")
static ConfigInstance resolveToInstance(ConfigKey<?> key, ConfigBuilder builder, InnerCNode targetDef) {
- ConfigDefinitionKey defKey = new ConfigDefinitionKey(key);
try {
if (targetDef != null) applyDef(builder, targetDef);
- ConfigInstance instance = getInstance(defKey, builder.getClass().getClassLoader());
- Class<? extends ConfigInstance> clazz = instance.getClass();
- return clazz.getConstructor(new Class<?>[]{builder.getClass()}).newInstance(builder);
+ Class<?> clazz = builder.getClass().getEnclosingClass();
+ if (!(ConfigInstance.class.isAssignableFrom(clazz))) {
+ throw new ConfigurationRuntimeException("Cannot produce config for the name '" + key.getName() + ", as "
+ + clazz.getName() + " is not a ConfigInstance.");
+ }
+ Class<? extends ConfigInstance> configClass = (Class<? extends ConfigInstance>)clazz;
+ Constructor<? extends ConfigInstance> constructor = configClass.getDeclaredConstructor(builder.getClass(), boolean.class);
+ constructor.setAccessible(true);
+ return constructor.newInstance(builder, /*throwIfUninitialized*/ false);
} catch (Exception e) {
throw new ConfigurationRuntimeException(e);
}
@@ -143,51 +150,6 @@ class InstanceResolver {
}
}
- /**
- * Create a ConfigBuilder given a definition key and a payload
- * @param key The key to use to create the correct builder.
- * @param payload The payload to populate the builder with.
- * @return A ConfigBuilder initialized with payload.
- */
- static ConfigBuilder createBuilderFromPayload(ConfigDefinitionKey key, VespaModel model, ConfigPayload payload, ConfigDefinition targetDef) {
- ConfigBuilder builderInstance = model.createBuilder(key, targetDef);
- if (builderInstance == null || builderInstance instanceof GenericConfig.GenericConfigBuilder) {
- if (log.isLoggable(LogLevel.SPAM)) {
- log.log(LogLevel.SPAM, "Creating generic builder for key=" + key);
- }
- return new GenericConfig.GenericConfigBuilder(key, new ConfigPayloadBuilder(payload));
- }
- ConfigTransformer transformer = new ConfigTransformer(builderInstance.getClass().getDeclaringClass());
- return transformer.toConfigBuilder(payload);
- }
-
- /**
- * Returns a {@link ConfigInstance} of right type for given key using reflection
- *
- * @param cKey a ConfigKey
- * @return a {@link ConfigInstance} or null if not available in classpath
- */
- static ConfigInstance getInstance(ConfigDefinitionKey cKey, ClassLoader instanceLoader) {
- String className = ConfigGenerator.createClassName(cKey.getName());
- Class<?> clazz;
- String fullClassName = packageName(cKey) + "." + className;
- try {
- clazz = instanceLoader != null ? instanceLoader.loadClass(fullClassName) : Class.forName(fullClassName);
- } catch (ClassNotFoundException e) {
- return null;
- }
- Object i;
- try {
- i = clazz.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new ConfigurationRuntimeException(e);
- }
- if (!(i instanceof ConfigInstance)) {
- throw new ConfigurationRuntimeException(fullClassName + " is not a ConfigInstance, can not produce config for the name '" + cKey.getName() + "'.");
- }
- return (ConfigInstance) i;
- }
-
static String packageName(ConfigDefinitionKey cKey) {
String prefix = "com.yahoo.";
return prefix + (cKey.getNamespace().isEmpty() ? CNode.DEFAULT_NAMESPACE : cKey.getNamespace());
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java
index 5f637090b73..5967771d904 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java
@@ -35,10 +35,9 @@ public class SystemMetrics {
// Disk metrics should be based on /home, or else '/' - or simply add filesystem as dimension
ImmutableSet.of(new Metric("cpu.busy.pct", CPU_UTIL),
new Metric("mem.used.pct", MEM_UTIL),
- new Metric("memory.usage", MEM_USED),
+ new Metric("mem.active.kb", MEM_USED),
new Metric("mem.total.kb", MEM_LIMIT),
- new Metric("fs.used.kb", DISK_USED),
- new Metric("fs.capacity.kb", DISK_LIMIT)
+ new Metric("used.kb", DISK_USED)
);
Set<Metric> systemMetrics = ImmutableSet.<Metric>builder()
diff --git a/config-model/src/main/perl/deploy b/config-model/src/main/perl/deploy
index 6c165951ab0..dc7b2132792 100755
--- a/config-model/src/main/perl/deploy
+++ b/config-model/src/main/perl/deploy
@@ -72,7 +72,7 @@ readConfFile();
use strict;
use warnings;
use feature qw(switch say);
-use vars qw/ $opt_h $opt_n $opt_v $opt_f $opt_t $opt_1 $opt_a $opt_e $opt_E $opt_r $opt_i $opt_p $opt_H $opt_R /;
+use vars qw/ $opt_c $opt_h $opt_n $opt_v $opt_f $opt_t $opt_a $opt_e $opt_E $opt_r $opt_i $opt_p $opt_H $opt_R /;
use Env qw($HOME);
use JSON;
use Getopt::Std;
@@ -99,15 +99,20 @@ my $environment = "prod";
my $region = "default";
my $instance = "default";
my $version = "v2";
+my $configserver = "";
my $port = "19071";
-getopts('fhnt:v1e:E:r:a:i:p:HR:');
+getopts('c:fhnt:ve:E:r:a:i:p:HR:');
if ($opt_h) {
usage();
exit 0;
}
+if ($opt_c) {
+ $configserver = $opt_c;
+}
+
if ($opt_e) {
$tenant = $opt_e;
}
@@ -132,13 +137,7 @@ if ($opt_p) {
$port = $opt_p;
}
-# Use v1 of application API
-if ($opt_1) {
- $version = "v1";
- $pathPrefix = "/application/v1/session";
-} else {
- $pathPrefix = "/application/v2/tenant/$tenant/session";
-}
+$pathPrefix = "/application/v2/tenant/$tenant/session";
create_cloudconfig_dir();
@@ -303,7 +302,13 @@ sub fetch_directory {
sub get_configsource_url {
my ($command) = @_;
- my @configsources = split(' ', `$VESPA_HOME/bin/vespa-print-default configservers_http`);
+ my @configsources;
+ if ($configserver and $configserver ne "") {
+ @configsources = ('http://' . $configserver . ':' . $port . '/');
+ } else {
+ @configsources = split(' ', `$VESPA_HOME/bin/vespa-print-default configservers_http`);
+ }
+
my $configsource_url = shift(@configsources);
if (!$configsource_url) {
die "Could not get url to config server, make sure that VESPA_HOME and services.addr_configserver is set\n";