This project has retired. For details please refer to its Attic page.
Source code
001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.wake;
020
021import org.apache.reef.tang.JavaConfigurationBuilder;
022import org.apache.reef.tang.Tang;
023import org.apache.reef.tang.annotations.Name;
024import org.apache.reef.tang.annotations.NamedParameter;
025import org.apache.reef.tang.annotations.Parameter;
026import org.apache.reef.tang.exceptions.BindException;
027import org.apache.reef.tang.formats.ConfigurationFile;
028import org.apache.reef.wake.exception.WakeRuntimeException;
029
030import javax.inject.Inject;
031import java.io.File;
032import java.io.IOException;
033import java.util.logging.Level;
034import java.util.logging.Logger;
035
036/**
037 * Wake parameter configuration
038 */
039public final class WakeConfiguration {
040  private final static Logger LOG = Logger.getLogger(WakeConfiguration.class.getName());
041
042  @Inject
043  public WakeConfiguration(final @Parameter(FileName.class) String confFileName) {
044    if (confFileName.equals("")) {
045      LOG.log(Level.WARNING, "The Wake configuration file is not specified.");
046    } else {
047      Tang t = Tang.Factory.getTang();
048      JavaConfigurationBuilder cb = t.newConfigurationBuilder();
049      try {
050        ConfigurationFile.addConfiguration(cb, new File(confFileName));
051      } catch (BindException e) {
052        throw new WakeRuntimeException(e);
053      } catch (IOException e) {
054        throw new WakeRuntimeException(e);
055      }
056    }
057  }
058
059  @NamedParameter(doc = "Configuration file name", default_value = "")
060  public final static class FileName implements Name<String> {
061  }
062}