Tabnine Logo
ServiceProfile.getConfiguration
Code IndexAdd Tabnine to your IDE (free)

How to use
getConfiguration
method
in
com.asakusafw.yaess.core.ServiceProfile

Best Java code snippets using com.asakusafw.yaess.core.ServiceProfile.getConfiguration (Showing top 20 results out of 315)

origin: asakusafw/asakusafw

private void configureVersion(ServiceProfile<?> profile) {
  assert profile != null;
  this.version = profile.getConfiguration(KEY_VERSION, true, false);
}
origin: asakusafw/asakusafw

private File prepareDirectory(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String path = profile.getConfiguration(KEY_DIRECTORY, true, true);
  File dir = new File(path);
  if (dir.isDirectory() == false && dir.mkdirs() == false) {
    throw new IOException(MessageFormat.format(
        "Failed to prepare lock directory: {0}",
        dir.getAbsolutePath()));
  }
  return dir;
}
origin: asakusafw/asakusafw

  /**
   * Merges this profile into the specified properties.
   * If properties already contains entries related to this profile,
   * then this method will overwrite them.
   * @param properties target properties
   * @throws IllegalArgumentException if some parameters were {@code null}
   */
  public void storeTo(Properties properties) {
    if (properties == null) {
      throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$
    }
    properties.setProperty(prefix, getServiceClass().getName());
    for (Map.Entry<String, String> entry : getConfiguration().entrySet()) {
      properties.setProperty(prefix + '.' + entry.getKey(), entry.getValue());
    }
  }
}
origin: asakusafw/asakusafw

/**
 * Returns the target configuration.
 * @param key the configuration key
 * @param mandatory whether the configuration is mandatory
 * @param resolve whether resolves the configuration
 * @return the corresponded configuration, or {@code null} if is not defined/empty
 * @throws IllegalArgumentException if some parameters were {@code null}
 * @since 0.4.0
 */
public String getConfiguration(String key, boolean mandatory, boolean resolve) {
  if (key == null) {
    throw new IllegalArgumentException("key must not be null"); //$NON-NLS-1$
  }
  String value = getConfiguration().get(key);
  return normalize(key, value, mandatory, resolve);
}
origin: asakusafw/asakusafw

private File getConfDirectory(ServiceProfile<?> profile) {
  assert profile != null;
  String value = profile.getConfiguration(KEY_DIRECTORY, true, true);
  File dir = new File(value);
  if (dir.exists() == false) {
    YSLOG.info("I00001",
        profile.getPrefix(),
        KEY_DIRECTORY,
        value);
  }
  return dir;
}
origin: asakusafw/asakusafw

private boolean extractBoolean(ServiceProfile<?> profile, String key, boolean defaultValue) throws IOException {
  assert profile != null;
  assert key != null;
  String string = profile.getConfiguration(key, false, true);
  if (string == null) {
    return defaultValue;
  }
  string = string.trim();
  if (string.isEmpty()) {
    return defaultValue;
  }
  try {
    return Boolean.parseBoolean(string);
  } catch (RuntimeException e) {
    throw new IOException(MessageFormat.format(
        "Failed to resolve boolean value ({0}={1})",
        profile.getPrefix() + '.' + key,
        string), e);
  }
}
origin: asakusafw/asakusafw

private void configureResourceId(ServiceProfile<?> profile) {
  assert profile != null;
  String override = profile.getConfiguration(ExecutionScriptHandler.KEY_RESOURCE, false, true);
  if (override == null) {
    LOG.debug("resourceId is not override in {}",
        profile.getPrefix());
    resourceId = ExecutionScriptHandler.DEFAULT_RESOURCE_ID;
  } else {
    LOG.debug("resourceId is overriden in {}: {}",
        profile.getPrefix(),
        override);
    resourceId = override;
  }
}
origin: asakusafw/asakusafw

private void configureStepUnit(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String stepUnitString = profile.getConfiguration(KEY_STEP_UNIT, false, true);
  if (stepUnitString == null) {
    LOG.debug("{} is not defined in {}", KEY_STEP_UNIT, profile.getPrefix());
  } else {
    try {
      stepUnit = Double.parseDouble(stepUnitString);
    } catch (NumberFormatException e) {
      throw new IOException(MessageFormat.format(
          "{0}.{1} must be a number: {2}",
          profile.getPrefix(),
          KEY_STEP_UNIT,
          stepUnitString));
    }
  }
}
origin: asakusafw/asakusafw

private List<String> extractCommand(ServiceProfile<?> profile, String prefix) throws IOException {
  try {
    return ProcessUtil.extractCommandLineTokens(
        prefix,
        profile.getConfiguration(),
        profile.getContext().getContextParameters());
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to resolve command line tokens ({0})",
        profile.getPrefix() + '.' + prefix + '*'), e);
  }
}
origin: asakusafw/asakusafw

private void configureScope(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String scopeSymbol = profile.getConfiguration(KEY_SCOPE, false, true);
  if (scopeSymbol == null) {
    scope = ExecutionLock.Scope.getDefault();
    LOG.debug("Lock scope is not defined, use default: {}",
        scope.getSymbol());
  } else {
    scope = ExecutionLock.Scope.findFromSymbol(scopeSymbol);
    if (scope == null) {
      throw new IOException(MessageFormat.format(
          "Unknown lock scope in \"{0}.{1}\": {2}",
          profile.getPrefix(),
          KEY_SCOPE,
          scopeSymbol));
    }
  }
}
origin: asakusafw/asakusafw

private List<String> extractCommand(
    ServiceProfile<?> profile,
    String prefix) throws IOException {
  try {
    return ProcessUtil.extractCommandLineTokens(
        prefix,
        profile.getConfiguration(),
        profile.getContext().getContextParameters());
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to resolve command line tokens ({0})",
        profile.getPrefix() + '.' + prefix + '*'), e);
  }
}
origin: asakusafw/asakusafw

@Override
public void configure(ServiceProfile<?> profile) throws IOException, InterruptedException {
  this.prefix = profile.getPrefix();
  try {
    this.confDirectory = getConfDirectory(profile);
    this.delegations = getDelegations(profile);
    this.forceSetUp = profile.getConfiguration(KEY_SETUP, false, true);
    this.forceCleanUp = profile.getConfiguration(KEY_CLEANUP, false, true);
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure \"{0}\" ({1})",
        profile.getPrefix(),
        profile.getServiceClass().getName()), e);
  }
  if (forceSetUp != null && delegations.containsKey(forceSetUp) == false) {
    throw new IOException(MessageFormat.format(
        "Failed to detect setUp target: \"{2}\" in {0}.{1}",
        profile.getPrefix(),
        KEY_SETUP,
        forceSetUp));
  }
  if (forceCleanUp != null && delegations.containsKey(forceCleanUp) == false) {
    throw new IOException(MessageFormat.format(
        "Failed to detect cleanUp target: \"{2}\" in {0}.{1}",
        profile.getPrefix(),
        KEY_CLEANUP,
        forceCleanUp));
  }
}
origin: asakusafw/asakusafw

@Override
protected void doConfigure(ServiceProfile<?> profile) throws InterruptedException, IOException {
  try {
    this.executor = ParallelJobExecutor.extract(
        profile.getPrefix(),
        profile.getConfiguration(),
        profile.getContext().getContextParameters());
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure job scheduler: {0}",
        profile.getPrefix()), e);
  }
}
origin: asakusafw/asakusafw

private void checkCleanupConfigurations(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String workingDirectory = profile.getConfiguration().get(KEY_WORKING_DIRECTORY);
  if (workingDirectory != null) {
    YSLOG.warn("W10001", profile.getPrefix(), KEY_WORKING_DIRECTORY, KEY_CLEANUP);
  }
  List<String> cleanupPrefix = extractCommand(profile, ProcessUtil.PREFIX_CLEANUP);
  if (cleanupPrefix.isEmpty() == false) {
    YSLOG.warn("W10001", profile.getPrefix(), ProcessUtil.PREFIX_CLEANUP + "*", KEY_CLEANUP);
  }
}
origin: asakusafw/asakusafw

@Override
protected void configureExtension(ServiceProfile<?> profile) throws InterruptedException, IOException {
  try {
    this.executor = JschProcessExecutor.extract(
        profile.getPrefix(),
        profile.getConfiguration(),
        profile.getContext().getContextParameters());
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure SSH: {0}",
        profile.getPrefix()), e);
  } catch (JSchException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure SSH: {0}",
        profile.getPrefix()), e);
  }
}
origin: asakusafw/asakusafw

private Map<String, ExecutionScriptHandler<T>> getDelegations(
    ServiceProfile<?> profile) throws IOException, InterruptedException {
  assert profile != null;
  Map<String, String> conf = profile.getConfiguration();
  Set<String> keys = PropertiesUtil.getChildKeys(conf, "", ".");
  keys.remove(PREFIX_CONF);
origin: asakusafw/asakusafw

@Override
protected void configureExtension(ServiceProfile<?> profile) throws InterruptedException, IOException {
  try {
    this.executor = JschProcessExecutor.extract(
        profile.getPrefix(),
        profile.getConfiguration(),
        profile.getContext().getContextParameters());
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure SSH: {0}",
        profile.getPrefix()), e);
  } catch (JSchException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure SSH: {0}",
        profile.getPrefix()), e);
  }
}
origin: asakusafw/asakusafw

private Map<String, String> getDesiredProperties(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  NavigableMap<String, String> vars = PropertiesUtil.createPrefixMap(
      profile.getConfiguration(),
      ExecutionScriptHandler.KEY_PROP_PREFIX);
  Map<String, String> resolved = new TreeMap<>();
origin: asakusafw/asakusafw

private Map<String, String> getDesiredEnvironmentVariables(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  NavigableMap<String, String> vars = PropertiesUtil.createPrefixMap(
      profile.getConfiguration(),
      ExecutionScriptHandler.KEY_ENV_PREFIX);
  Map<String, String> resolved = new TreeMap<>();
origin: asakusafw/asakusafw

  throw new IllegalArgumentException("profile must not be null"); //$NON-NLS-1$
Map<String, String> conf = new HashMap<>(profile.getConfiguration());
conf.remove(ExecutionScriptHandler.KEY_RESOURCE);
removeKeyPrefix(conf, ExecutionScriptHandler.KEY_PROP_PREFIX);
com.asakusafw.yaess.coreServiceProfilegetConfiguration

Javadoc

Return the optional configuration for the service.

Popular methods of ServiceProfile

  • getContext
    Returns the current profile context.
  • getPrefix
    Returns the key prefix of this profile.
  • getServiceClass
    Returns the service class.
  • load
    Loads a service profile with the specified key prefix.
  • newInstance
    Creates a new instance. The created service will automatically Service#configure(ServiceProfile)by u
  • normalize
    Normalizes the configuration value.
  • <init>
    Creates a new instance.

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSharedPreferences (Context)
  • getApplicationContext (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • BoxLayout (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now