Java 类javax.naming.ConfigurationException 实例源码

项目:RedisClusterManager    文件:AppMain.java   
public static void main(String[] args) throws Exception {
    ArgsUtil util = ArgsUtil.parser(args);
    Long period = util.getLong("period");
    if(period == null){
        period = 300L;
    }
    final String website = util.getString("website");
    if(website == null || "".equals(website)){
        throw new ConfigurationException("please enter args[website], to configure the reporting website! example:[--website=http://localhost:8080/metric]");
    }
    final String ip = util.getString("ip");
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            try {
                Map<String, String> info = MonitorUtil.getSystemInfo(ip);
                RestTemplate.send(website, info);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, 0, period  * 1000);
}
项目:bazel-buildfarm    文件:Worker.java   
public Worker(WorkerConfig config) throws ConfigurationException {
  this.config = config;

  /* configuration validation */
  root = getValidRoot(config);
  Path casCacheDirectory = getValidCasCacheDirectory(config, root);

  /* initialization */
  instance = new StubInstance(
      config.getInstanceName(),
      createChannel(config.getOperationQueue()));
  InputStreamFactory inputStreamFactory = new InputStreamFactory() {
    @Override
    public InputStream apply(Digest digest) {
      return instance.newStreamInput(instance.getBlobName(digest));
    }
  };
  fileCache = new CASFileCache(
      inputStreamFactory,
      root.resolve(casCacheDirectory),
      config.getCasCacheMaxSizeBytes());
}
项目:rdf2x    文件:DbConfig.java   
/**
 * Prepare Properties object for JDBC Connector
 *
 * @return prepared Properties object for JDBC Connector
 */
public Properties getProperties() {
    Properties dbProperties = new Properties();

    try {
        // specify driver class name, required by Spark to register it on all executors
        dbProperties.put("driver", getDriverClassName());
    } catch (ConfigurationException ignored) {
        // already checked during validation
    }
    dbProperties.put("tcpKeepAlive", "true");
    dbProperties.put("connectTimeout", "0");
    dbProperties.put("socketTimeout", "0");
    dbProperties.setProperty("user", user);
    dbProperties.setProperty("password", password);
    dbProperties.setProperty("batchsize", batchSize.toString());
    if (schema != null) {
        dbProperties.put("searchpath", schema);
        dbProperties.put("currentSchema", schema);
    }
    return dbProperties;
}
项目:cosmic    文件:GenericDaoBase.java   
@Override
@DB()
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _name = name;

    final String value = (String) params.get("lock.timeout");
    _timeoutSeconds = NumbersUtil.parseInt(value, 300);

    createCache(params);
    final boolean load = Boolean.parseBoolean((String) params.get("cache.preload"));
    if (load) {
        listAll();
    }

    return true;
}
项目:cosmic    文件:AgentShell.java   
private ServerResource loadServerResource(final String resourceClassName) throws ConfigurationException {
    logger.debug("Loading agent resource from class name {}", resourceClassName);
    final String[] names = resourceClassName.split("\\|");
    for (final String name : names) {
        final Class<?> impl;
        try {
            impl = Class.forName(name);
            final Constructor<?> constructor = impl.getDeclaredConstructor();
            constructor.setAccessible(true);
            return (ServerResource) constructor.newInstance();
        } catch (final ClassNotFoundException
                | SecurityException
                | NoSuchMethodException
                | IllegalArgumentException
                | InstantiationException
                | IllegalAccessException
                | InvocationTargetException e) {
            throw new ConfigurationException("Failed to launch agent due to " + e.getClass().getSimpleName() + ": " + e.getMessage());
        }
    }
    throw new ConfigurationException("Could not find server resource class to load in: " + resourceClassName);
}
项目:cosmic    文件:LibvirtVifDriverTest.java   
@Test
public void testWhenExplicitlySetDifferentDefault() throws ConfigurationException {

    // Tests when explicitly set vif driver to OVS when using regular bridges and vice versa
    final Map<String, Object> params = new HashMap<>();

    // Switch res' bridge type for test purposes
    params.put(LibVirtVifDriver, LibvirtComputingResource.DEFAULT_OVS_VIF_DRIVER_CLASS);
    res.setBridgeType(BridgeType.NATIVE);
    configure(params);
    checkAllSame(ovsVifDriver);

    params.clear();
    params.put(LibVirtVifDriver, LibvirtComputingResource.DEFAULT_BRIDGE_VIF_DRIVER_CLASS);
    res.setBridgeType(BridgeType.OPENVSWITCH);
    configure(params);
    checkAllSame(bridgeVifDriver);
}
项目:nettice    文件:RouterConfig.java   
private static RouterConfig parse(File configFile) throws Exception{
    RouterConfig config = new RouterConfig();
    SAXReader saxReader = new SAXReader();
    Document document = null;
    try{
        document = saxReader.read(new InputSource(new FileInputStream(configFile)));
    }catch(DocumentException e){
        throw new ConfigurationException("config file parse error");
    }
    if(document != null){
        Element rootElement = document.getRootElement();
        Iterator<?> ie = rootElement.elementIterator();
        while(ie.hasNext()){
            Element element = (Element) ie.next();
            if("action-package".equals(element.getName())){
                config.actionPackages = parseActionPackages(element);
            }else if("namespaces".equals(element.getName())){
                config.namespaces = parseNamespaces(element);
            }
        }
    }
    return config;
}
项目:cosmic    文件:AbstractStoragePoolAllocator.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);
    if (_configDao != null) {
        final Map<String, String> configs = _configDao.getConfiguration(null, params);
        final String globalStorageOverprovisioningFactor = configs.get("storage.overprovisioning.factor");
        _storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(globalStorageOverprovisioningFactor, 2.0f));
        _extraBytesPerVolume = 0;
        _rand = new Random(System.currentTimeMillis());
        _dontMatter = Boolean.parseBoolean(configs.get("storage.overwrite.provisioning"));
        final String allocationAlgorithm = configs.get("vm.allocation.algorithm");
        if (allocationAlgorithm != null) {
            _allocationAlgorithm = allocationAlgorithm;
        }
        return true;
    }
    return false;
}
项目:cosmic    文件:KvmStorageProcessor.java   
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    storageLayer = new JavaStorageLayer();
    storageLayer.configure("StorageLayer", params);

    String storageScriptsDir = (String) params.get("storage.scripts.dir");
    if (storageScriptsDir == null) {
        storageScriptsDir = getDefaultStorageScriptsDir();
    }

    createTmplPath = Script.findScript(storageScriptsDir, "createtmplt.sh");
    if (createTmplPath == null) {
        throw new ConfigurationException("Unable to find the createtmplt.sh");
    }

    manageSnapshotPath = Script.findScript(storageScriptsDir, "managesnapshot.sh");
    if (manageSnapshotPath == null) {
        throw new ConfigurationException("Unable to find the managesnapshot.sh");
    }

    cmdsTimeout = ((Integer) params.get("cmds.timeout")) * 1000;
    return true;
}
项目:cosmic    文件:ImageStoreDaoImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);

    nameSearch = createSearchBuilder();
    nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
    nameSearch.and("role", nameSearch.entity().getRole(), SearchCriteria.Op.EQ);
    nameSearch.done();

    providerSearch = createSearchBuilder();
    providerSearch.and("providerName", providerSearch.entity().getProviderName(), SearchCriteria.Op.EQ);
    providerSearch.and("role", providerSearch.entity().getRole(), SearchCriteria.Op.EQ);
    providerSearch.done();

    regionSearch = createSearchBuilder();
    regionSearch.and("scope", regionSearch.entity().getScope(), SearchCriteria.Op.EQ);
    regionSearch.and("role", regionSearch.entity().getRole(), SearchCriteria.Op.EQ);
    regionSearch.done();

    return true;
}
项目:cosmic    文件:DataCenterVnetDaoImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    final boolean result = super.configure(name, params);

    countVnetsDedicatedToAccount = createSearchBuilder(Integer.class);
    countVnetsDedicatedToAccount.and("dc", countVnetsDedicatedToAccount.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    countVnetsDedicatedToAccount.and("accountGuestVlanMapId", countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(), Op.NNULL);
    AccountGuestVlanMapSearch = _accountGuestVlanMapDao.createSearchBuilder();
    AccountGuestVlanMapSearch.and("accountId", AccountGuestVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    countVnetsDedicatedToAccount.join("AccountGuestVlanMapSearch", AccountGuestVlanMapSearch, countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(),
            AccountGuestVlanMapSearch.entity().getId(), JoinBuilder.JoinType.INNER);
    countVnetsDedicatedToAccount.select(null, Func.COUNT, countVnetsDedicatedToAccount.entity().getId());
    countVnetsDedicatedToAccount.done();
    AccountGuestVlanMapSearch.done();

    return result;
}
项目:cosmic    文件:DataCenterDaoImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    if (!super.configure(name, params)) {
        return false;
    }

    final String value = (String) params.get("mac.address.prefix");
    _prefix = (long) NumbersUtil.parseInt(value, 06) << 40;

    if (!_ipAllocDao.configure("Ip Alloc", params)) {
        return false;
    }

    if (!_vnetAllocDao.configure("vnet Alloc", params)) {
        return false;
    }
    return true;
}
项目:cosmic    文件:AuthenticatorTest.java   
@Before
public void setUp() throws Exception {
    try {
        authenticator.configure("SHA256", Collections.<String, Object>emptyMap());
    } catch (final ConfigurationException e) {
        fail(e.toString());
    }

    when(_userAccountDao.getUserAccount("admin", 0L)).thenReturn(adminAccount);
    when(_userAccountDao.getUserAccount("admin20Byte", 0L)).thenReturn(adminAccount20Byte);
    when(_userAccountDao.getUserAccount("fake", 0L)).thenReturn(null);
    //32 byte salt, and password="password"
    when(adminAccount.getPassword()).thenReturn("WS3UHhBPKHZeV+G3jnn7G2N3luXgLSfL+2ORDieXa1U=:VhuFOrOU2IpsjKYH8cH1VDaDBh/VivjMcuADjeEbIig=");
    //20 byte salt, and password="password"
    when(adminAccount20Byte.getPassword()).thenReturn("QL2NsxVEmRuDaNRkvIyADny7C5w=:JoegiytiWnoBAxmSD/PwBZZYqkr746x2KzPrZNw4NgI=");
}
项目:cosmic    文件:LibvirtComputingResource.java   
private Connect connectToHypervisor() throws ConfigurationException {
    Connect conn = null;
    try {
        conn = LibvirtConnection.getConnection();

        if (getBridgeType() == OPENVSWITCH) {
            if (conn.getLibVirVersion() < 10 * 1000 + 0) {
                throw new ConfigurationException("Libvirt version 0.10.0 required for openvswitch support, but version "
                        + conn.getLibVirVersion() + " detected");
            }
        }
    } catch (final LibvirtException e) {
        throw new CloudRuntimeException(e.getMessage());
    }
    return conn;
}
项目:cosmic    文件:LibvirtVifDriverTest.java   
@Test
public void testDefaultsWhenExplicitlySet() throws ConfigurationException {

    final Map<String, Object> params = new HashMap<>();

    // Switch res' bridge type for test purposes
    params.put(LibVirtVifDriver, LibvirtComputingResource.DEFAULT_BRIDGE_VIF_DRIVER_CLASS);
    res.setBridgeType(BridgeType.NATIVE);
    configure(params);
    checkAllSame(bridgeVifDriver);

    params.clear();
    params.put(LibVirtVifDriver, LibvirtComputingResource.DEFAULT_OVS_VIF_DRIVER_CLASS);
    res.setBridgeType(BridgeType.OPENVSWITCH);
    configure(params);
    checkAllSame(ovsVifDriver);
}
项目:ccs    文件:ContainerClusterManagerImpl.java   
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    _name = name;
    _configParams = params;
    _gcExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Container-Cluster-Scavenger"));
    _stateScanner = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Container-Cluster-State-Scanner"));

    final KeystoreVO keyStoreVO = keystoreDao.findByName(CCS_ROOTCA_KEYPAIR);
    if (keyStoreVO == null) {
            try {
                final KeyPair keyPair = generateRandomKeyPair();
                final String rootCACert = x509CertificateToPem(generateRootCACertificate(keyPair));
                final String rootCAKey = rsaPrivateKeyToPem(keyPair.getPrivate());
                keystoreDao.save(CCS_ROOTCA_KEYPAIR, rootCACert, rootCAKey, "");
                s_logger.info("No Container Cluster CA stores found, created and saved a keypair with certificate: \n" + rootCACert);
            } catch (NoSuchProviderException | NoSuchAlgorithmException | CertificateEncodingException | SignatureException | InvalidKeyException | IOException e) {
                s_logger.error("Unable to create and save CCS rootCA keypair: " + e.toString());
            }
    }
    return true;
}
项目:cosmic    文件:ApiDiscoveryTest.java   
@BeforeClass
public static void setUp() throws ConfigurationException {
    testApiName = testCmdClass.getAnnotation(APICommand.class).name();
    testApiDescription = testCmdClass.getAnnotation(APICommand.class).description();
    testApiSince = testCmdClass.getAnnotation(APICommand.class).since();
    testApiAsync = false;
    testUser = new UserVO();

    s_discoveryService._apiAccessCheckers = mock(List.class);
    s_discoveryService._services = mock(List.class);

    when(s_apiChecker.checkAccess(any(User.class), anyString())).thenReturn(true);
    when(s_pluggableService.getCommands()).thenReturn(new ArrayList<>());
    when(s_discoveryService._apiAccessCheckers.iterator()).thenReturn(Arrays.asList(s_apiChecker).iterator());
    when(s_discoveryService._services.iterator()).thenReturn(Arrays.asList(s_pluggableService).iterator());

    final Set<Class<?>> cmdClasses = new HashSet<>();
    cmdClasses.add(ListApisCmd.class);
    s_discoveryService.start();
    s_discoveryService.cacheResponseMap(cmdClasses);
}
项目:cosmic    文件:ApiRateLimitTest.java   
@BeforeClass
public static void setUp() throws ConfigurationException {
    when(s_configDao.getValue(Config.ApiLimitInterval.key())).thenReturn(null);
    when(s_configDao.getValue(Config.ApiLimitMax.key())).thenReturn(null);
    when(s_configDao.getValue(Config.ApiLimitCacheSize.key())).thenReturn(null);
    when(s_configDao.getValue(Config.ApiLimitEnabled.key())).thenReturn("true"); // enable api rate limiting
    s_limitService._configDao = s_configDao;

    s_limitService.configure("ApiRateLimitTest", Collections.<String, Object>emptyMap());

    s_limitService._accountService = s_accountService;

    // Standard responses
    final AccountVO acct = new AccountVO(s_acctIdSeq);
    acct.setType(Account.ACCOUNT_TYPE_NORMAL);
    acct.setAccountName("demo");
    s_testAccount = acct;

    when(s_accountService.getAccount(5L)).thenReturn(s_testAccount);
    when(s_accountService.isRootAdmin(5L)).thenReturn(false);
}
项目:cosmic    文件:ControlNetworkGuru.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);

    final Map<String, String> dbParams = _configDao.getConfiguration(params);

    _cidr = dbParams.get(Config.ControlCidr.toString());
    if (_cidr == null) {
        _cidr = "169.254.0.0/16";
    }

    _gateway = dbParams.get(Config.ControlGateway.toString());
    if (_gateway == null) {
        _gateway = NetUtils.getLinkLocalGateway();
    }

    s_logger.info("Control network setup: cidr=" + _cidr + "; gateway = " + _gateway);

    return true;
}
项目:cosmic    文件:RemoteAccessVpnManagerImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    final Map<String, String> configs = _configDao.getConfiguration(params);

    _userLimit = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnUserLimit.key()), 8);

    _pskLength = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnPskLength.key()), 24);

    validateRemoteAccessVpnConfiguration();

    VpnSearch = _remoteAccessVpnDao.createSearchBuilder();
    VpnSearch.and("accountId", VpnSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    final SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
    domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
    VpnSearch.join("domainSearch", domainSearch, VpnSearch.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
    VpnSearch.done();

    return true;
}
项目:cosmic    文件:RemoteAccessVpnManagerImpl.java   
private void validateRemoteAccessVpnConfiguration() throws ConfigurationException {
    final String ipRange = RemoteAccessVpnClientIpRange.value();
    if (ipRange == null) {
        s_logger.warn("Remote Access VPN global configuration missing client ip range -- ignoring");
        return;
    }
    final Integer pskLength = _pskLength;
    if (pskLength != null && (pskLength < 8 || pskLength > 256)) {
        throw new ConfigurationException("Remote Access VPN: IPSec preshared key length should be between 8 and 256");
    }

    final String[] range = ipRange.split("-");
    if (range.length != 2) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip range " + ipRange);
    }
    if (!NetUtils.isValidIp4(range[0]) || !NetUtils.isValidIp4(range[1])) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip in range specification " + ipRange);
    }
    if (!NetUtils.validIpRange(range[0], range[1])) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip range " + ipRange);
    }
}
项目:cosmic    文件:ResourceManagerImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _defaultSystemVMHypervisor = HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString()));
    _gson = GsonHelper.getGson();

    _hypervisorsInDC = _hostDao.createSearchBuilder(String.class);
    _hypervisorsInDC.select(null, Func.DISTINCT, _hypervisorsInDC.entity().getHypervisorType());
    _hypervisorsInDC.and("hypervisorType", _hypervisorsInDC.entity().getHypervisorType(), SearchCriteria.Op.NNULL);
    _hypervisorsInDC.and("dataCenter", _hypervisorsInDC.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    _hypervisorsInDC.and("id", _hypervisorsInDC.entity().getId(), SearchCriteria.Op.NEQ);
    _hypervisorsInDC.and("type", _hypervisorsInDC.entity().getType(), SearchCriteria.Op.EQ);
    _hypervisorsInDC.done();

    _gpuAvailability = _hostGpuGroupsDao.createSearchBuilder();
    _gpuAvailability.and("hostId", _gpuAvailability.entity().getHostId(), Op.EQ);
    _gpuAvailability.and("groupName", _gpuAvailability.entity().getGroupName(), Op.EQ);
    final SearchBuilder<VGPUTypesVO> join1 = _vgpuTypesDao.createSearchBuilder();
    join1.and("vgpuType", join1.entity().getVgpuType(), Op.EQ);
    join1.and("remainingCapacity", join1.entity().getRemainingCapacity(), Op.GT);
    _gpuAvailability.join("groupId", join1, _gpuAvailability.entity().getId(), join1.entity().getGpuGroupId(), JoinBuilder.JoinType.INNER);
    _gpuAvailability.done();

    return true;
}
项目:cosmic    文件:DiscovererBase.java   
@Override
public ServerResource reloadResource(final HostVO host) {
    final String resourceName = host.getResource();
    final ServerResource resource = getResource(resourceName);

    if (resource != null) {
        _hostDao.loadDetails(host);
        updateNetworkLabels(host);

        final HashMap<String, Object> params = buildConfigParams(host);
        try {
            resource.configure(host.getName(), params);
        } catch (final ConfigurationException e) {
            s_logger.warn("Unable to configure resource due to " + e.getMessage());
            return null;
        }
        if (!resource.start()) {
            s_logger.warn("Unable to start the resource");
            return null;
        }
    }
    return resource;
}
项目:cosmic    文件:AccountManagerImpl.java   
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
    if (_systemAccount == null) {
        throw new ConfigurationException("Unable to find the system account using " + Account.ACCOUNT_ID_SYSTEM);
    }

    _systemUser = _userDao.findById(User.UID_SYSTEM);
    if (_systemUser == null) {
        throw new ConfigurationException("Unable to find the system user using " + User.UID_SYSTEM);
    }

    final Map<String, String> configs = _configDao.getConfiguration(params);

    final String loginAttempts = configs.get(Config.IncorrectLoginAttemptsAllowed.key());
    _allowedLoginAttempts = NumbersUtil.parseInt(loginAttempts, 5);

    final String value = configs.get(Config.AccountCleanupInterval.key());
    _cleanupInterval = NumbersUtil.parseInt(value, 60 * 60 * 24); // 1 day.

    return true;
}
项目:OpenJSharp    文件:StartTlsRequest.java   
private ConfigurationException wrapException(Exception e) {
    ConfigurationException ce = new ConfigurationException(
        "Cannot load implementation of javax.naming.ldap.StartTlsResponse");

    ce.setRootCause(e);
    return ce;
}
项目:parabuild-ci    文件:JNDIAuthenticator.java   
/**
 * Check whether the credentials presented by the user match those
 * retrieved from the directory.
 *
 * @param info        The User to be authenticated
 * @param credentials Authentication credentials
 */
private boolean compareCredentials(final JNDIUser info, final String credentials) throws ConfigurationException {
  try {
    if (info == null || credentials == null) {
      return false;
    }
    final String password = info.getPassword();
    if (log.isDebugEnabled()) {
      log.debug("user password: " + password);
    }
    if (log.isDebugEnabled()) {
      log.debug("digestAlgorithm: " + digestAlgorithm);
    }
    if (password == null) {
      return false;
    }
    if (log.isDebugEnabled()) {
      log.debug("Validate the credentials specified by the user");
    }
    boolean validated = false;
    if (StringUtils.isBlank(digestAlgorithm)) {
      validated = digest(credentials).equals(password);
    } else {
      if (password.toUpperCase().startsWith("{SHA}")) {
        validated = digestCredentialsAndValidate(credentials, password.substring(5));
      } else if (password.toUpperCase().startsWith("{MD5}")) {
        validated = digestCredentialsAndValidate(credentials, password.substring(5));
      } else {
        // Hex hashes should be compared case-insensitive
        validated = digest(credentials).equalsIgnoreCase(password);
      }
    }
    return validated;
  } catch (NoSuchAlgorithmException e) {
    final ConfigurationException ce = new ConfigurationException(StringUtils.toString(e));
    ce.initCause(e);
    throw ce;
  }
}
项目:jdk8u-jdk    文件:StartTlsRequest.java   
private ConfigurationException wrapException(Exception e) {
    ConfigurationException ce = new ConfigurationException(
        "Cannot load implementation of javax.naming.ldap.StartTlsResponse");

    ce.setRootCause(e);
    return ce;
}
项目:openjdk-jdk10    文件:StartTlsRequest.java   
private ConfigurationException wrapException(Exception e) {
    ConfigurationException ce = new ConfigurationException(
        "Cannot load implementation of javax.naming.ldap.StartTlsResponse");

    ce.setRootCause(e);
    return ce;
}
项目:feeyo-redisproxy    文件:ConfigLoader.java   
/**
 *  获取连接池配置
 * 
 * @param uri
 * @return
 */
public static Map<Integer, PoolCfg> loadPoolMap(String uri) {

    Map<Integer, PoolCfg> map = new HashMap<Integer, PoolCfg>();

    try {

        NodeList nodesElements = loadXmlDoc( uri ).getElementsByTagName("pool");
        for (int i = 0; i < nodesElements.getLength(); i++) {
            Node nodesElement = nodesElements.item(i);

            NamedNodeMap nameNodeMap = nodesElement.getAttributes();
            int id = getIntAttribute(nameNodeMap, "id", -1);
            String name = getAttribute(nameNodeMap, "name", null);
            int type = getIntAttribute(nameNodeMap, "type", 0);
            int minCon = getIntAttribute(nameNodeMap, "minCon", 5);
            int maxCon = getIntAttribute(nameNodeMap, "maxCon", 100);

            PoolCfg poolCfg = new PoolCfg(id, name, type, minCon, maxCon);
            List<Node> nodeList = getChildNodes(nodesElement, "node");
            for(int j = 0; j < nodeList.size(); j++) {
                Node node = nodeList.get(j);                    
                NamedNodeMap attrs = node.getAttributes();
                String ip = getAttribute(attrs, "ip", null);
                int port = getIntAttribute(attrs, "port", 6379);
                String suffix = getAttribute(attrs, "suffix", null);
                if(suffix == null && type == 2) {
                    throw new ConfigurationException("Customer Cluster nodes need to set unique suffix property");
                }
                else
                    poolCfg.addNode( ip + ":" + port + ":" + suffix);
            }
            map.put(id,  poolCfg);
        }
    } catch (Exception e) {
        LOGGER.error("loadPoolCfg err " + e);
    }
    return map;
}
项目:bazel-buildfarm    文件:Worker.java   
private static Path getValidRoot(WorkerConfig config) throws ConfigurationException {
  String rootValue = config.getRoot();
  if (Strings.isNullOrEmpty(rootValue)) {
    throw new ConfigurationException("root value in config missing");
  }
  return Paths.get(rootValue);
}
项目:bazel-buildfarm    文件:Worker.java   
private static Path getValidCasCacheDirectory(WorkerConfig config, Path root) throws ConfigurationException {
  String casCacheValue = config.getCasCacheDirectory();
  if (Strings.isNullOrEmpty(casCacheValue)) {
    throw new ConfigurationException("Cas cache directory value in config missing");
  }
  return root.resolve(casCacheValue);
}
项目:rdf2x    文件:Main.java   
/**
 * Get job based on command-line arguments and run it.
 *
 * @param args command-line arguments
 * @throws ConfigurationException in case config is not valid
 */
public static void main(String args[]) throws ConfigurationException {
    Runnable job = JobFactory.getJob(args);

    if (job == null) {
        return;
    }

    job.run();
}
项目:rdf2x    文件:PersistorFactory.java   
public static Persistor createPersistor(OutputConfig config) {
    OutputConfig.OutputTarget target = config.getTarget();
    switch (target) {
        case DB:
            try {
                String driverClassName = config.getDbConfig().getDriverClassName();
                switch (driverClassName) {
                    case "org.postgresql.Driver":
                        return new DbPersistorPostgres(config.getDbConfig(), config.getSaveMode());
                    case "com.microsoft.sqlserver.jdbc.SQLServerDriver":
                        return new DbPersistorSQLServer(config.getDbConfig(), config.getSaveMode());
                }
            } catch (ConfigurationException ignored) {
            }
            return new DbPersistor(config.getDbConfig(), config.getSaveMode());
        case CSV:
            return new CSVPersistor(config.getFileConfig(), config.getSaveMode());
        case JSON:
            return new JSONPersistor(config.getFileConfig(), config.getSaveMode());
        case ES:
            return new ElasticSearchPersistor(config.getEsConfig());
        case Preview:
            return new PreviewPersistor();
        case DataFrameMap:
            return new DataFrameMapPersistor(config.getResultMap());
        default:
            throw new NotImplementedException("Output not supported: " + config);
    }
}
项目:rdf2x    文件:FileConfig.java   
/**
 * Validate the config, throw {@link ConfigurationException} on error
 *
 * @throws ConfigurationException found error
 */
public void validate() throws ConfigurationException {
    if (outputFolder == null) {
        throw new ConfigurationException("Specify the output folder with --output.folder");
    }
    File f = new File(outputFolder);
    if (f.exists() && !f.isDirectory()) {
        throw new ConfigurationException("The output path is not a folder: " + outputFolder);
    }
}
项目:rdf2x    文件:DbConfig.java   
/**
 * Validate the config, throw {@link ConfigurationException} on error
 *
 * @throws ConfigurationException found error
 */
public void validate() throws ConfigurationException {
    if (url == null) {
        throw new ConfigurationException("Specify JDBC url with --db.url");
    }
    if (user == null) {
        throw new ConfigurationException("Specify DB user with --db.user");
    }
    getDriverClassName();
}
项目:rdf2x    文件:DbConfig.java   
public String getDriverClassName() throws ConfigurationException {
    try {
        return DriverManager.getDriver(url).getClass().getName();
    } catch (SQLException e) {
        throw new ConfigurationException("Driver not found for JDBC url '" + url + "', probably due to missing dependencies");
    }
}
项目:rdf2x    文件:OutputConfig.java   
/**
 * Validate the config, throw {@link ConfigurationException} on error
 *
 * @throws ConfigurationException found error
 */
public void validate() throws ConfigurationException {
    switch (target) {
        case DB:
            dbConfig.validate();
            break;
        case CSV:
        case JSON:
            fileConfig.validate();
            break;
        case ES:
            esConfig.validate();
            break;
    }
}
项目:rdf2x    文件:JobFactoryTest.java   
@Test
public void testGetPersistJob() throws ConfigurationException {
    Runnable job = JobFactory.getJob(new String[]{"convert", "--input.file", "test.nq", "--output.target", "Preview"});
    // stop the created Spark Context to avoid conflicts in other tests
    SparkContext.getOrCreate().stop();
    assertNotNull("Non-null write job returned from factory", job);
    assertEquals("Correct job returned from factory", ConvertJob.class, job.getClass());
}
项目:openjdk9    文件:StartTlsRequest.java   
private ConfigurationException wrapException(Exception e) {
    ConfigurationException ce = new ConfigurationException(
        "Cannot load implementation of javax.naming.ldap.StartTlsResponse");

    ce.setRootCause(e);
    return ce;
}
项目:cosmic    文件:LibvirtVifDriverTest.java   
private void checkAllSame(final VifDriver vifDriver) throws ConfigurationException {

        for (final TrafficType trafficType : TrafficType.values()) {
            assertions.put(trafficType, vifDriver);
        }

        checkAssertions();
    }