java.net.UnknownHostException#getLocalizedMessage ( )源码实例Demo

下面列出了java.net.UnknownHostException#getLocalizedMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: archivo   文件: Tivo.java
/**
 * Create a new Tivo object from a JSON String.
 *
 * @param json String containing the Tivo object in JSON
 * @param mak  Media access key to use for the resulting Tivo
 * @return A new Tivo object
 * @throws IllegalArgumentException on invalid address
 */
public static Tivo fromJSON(final String json, final String mak) throws IllegalArgumentException {
    JSONObject jo = new JSONObject(json);
    String name = jo.getString(JSON_NAME);
    String tsn = jo.getString(JSON_TSN);
    int port = jo.getInt(JSON_PORT);
    JSONArray jsonAddresses = jo.getJSONArray(JSON_ADDRESSES);
    Set<InetAddress> addresses = new HashSet<>();
    Base64.Decoder decoder = Base64.getDecoder();
    for (int i = 0; i < jsonAddresses.length(); i++) {
        try {
            addresses.add(InetAddress.getByAddress(decoder.decode(jsonAddresses.getString(i))));
        } catch (UnknownHostException e) {
            throw new IllegalArgumentException("TiVo address in invalid: " + e.getLocalizedMessage());
        }
    }

    return new Builder().name(name).tsn(tsn).port(port).addresses(addresses).mak(mak).build();
}
 
源代码2 项目: EDDI   文件: PersistenceModule.java
@Provides
@Singleton
public MongoDatabase provideMongoDB(@Named("mongodb.hosts") String hosts,
                                    @Named("mongodb.port") Integer port,
                                    @Named("mongodb.database") String database,
                                    @Named("mongodb.source") String source,
                                    @Named("mongodb.username") String username,
                                    @Named("mongodb.password") String password,
                                    @Named("mongodb.connectionsPerHost") Integer connectionsPerHost,
                                    @Named("mongodb.connectTimeout") Integer connectTimeout,
                                    @Named("mongodb.heartbeatConnectTimeout") Integer heartbeatConnectTimeout,
                                    @Named("mongodb.heartbeatFrequency") Integer heartbeatFrequency,
                                    @Named("mongodb.heartbeatSocketTimeout") Integer heartbeatSocketTimeout,
                                    @Named("mongodb.localThreshold") Integer localThreshold,
                                    @Named("mongodb.maxConnectionIdleTime") Integer maxConnectionIdleTime,
                                    @Named("mongodb.maxConnectionLifeTime") Integer maxConnectionLifeTime,
                                    @Named("mongodb.maxWaitTime") Integer maxWaitTime,
                                    @Named("mongodb.minConnectionsPerHost") Integer minConnectionsPerHost,
                                    @Named("mongodb.minHeartbeatFrequency") Integer minHeartbeatFrequency,
                                    @Named("mongodb.requiredReplicaSetName") String requiredReplicaSetName,
                                    @Named("mongodb.serverSelectionTimeout") Integer serverSelectionTimeout,
                                    @Named("mongodb.socketTimeout") Integer socketTimeout,
                                    @Named("mongodb.sslEnabled") Boolean sslEnabled,
                                    @Named("mongodb.threadsAllowedToBlockForConnectionMultiplier") Integer threadsAllowedToBlockForConnectionMultiplier,
                                    BsonFactory bsonFactory) {
    try {

        List<ServerAddress> seeds = hostsToServerAddress(hosts, port);

        MongoClient mongoClient;
        MongoClientOptions mongoClientOptions = buildMongoClientOptions(
                ReadPreference.nearest(), connectionsPerHost, connectTimeout,
                heartbeatConnectTimeout, heartbeatFrequency, heartbeatSocketTimeout,
                localThreshold, maxConnectionIdleTime, maxConnectionLifeTime, maxWaitTime,
                minConnectionsPerHost, minHeartbeatFrequency, requiredReplicaSetName,
                serverSelectionTimeout, socketTimeout, sslEnabled,
                threadsAllowedToBlockForConnectionMultiplier, bsonFactory);
        if ("".equals(username) || "".equals(password)) {
            mongoClient = new MongoClient(seeds, mongoClientOptions);
        } else {
            MongoCredential credential = MongoCredential.createCredential(username, source, password.toCharArray());
            mongoClient = new MongoClient(seeds, credential, mongoClientOptions);
        }

        registerMongoClientShutdownHook(mongoClient);

        return mongoClient.getDatabase(database);
    } catch (UnknownHostException e) {
        throw new RuntimeException(e.getLocalizedMessage(), e);
    }
}
 
源代码3 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(String host, int port, Properties props, UsageOptions opts, boolean secure)
                        throws ConfigException, ConnectionException {
        super.init(host, port, props, opts, secure);
        try {
    			this.cmdMapArgs = new HashMap<String, Object>();
    			this.cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, "");
                this.relaxCmdNameValidationChecks = RpcPropertyDefs.getPropertyAsBoolean(props,
                                                        RpcPropertyDefs.RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
                this.applicationName = RpcPropertyDefs.getProperty(props,
                        								RpcPropertyDefs.RPC_APPLICATION_NAME_NICK, null);
                if (this.getUsageOptions().getHostName() != null) {
                        // This had better reflect reality...
                        this.localHostName = this.getUsageOptions().getHostName();
                } else {
                        this.localHostName = java.net.InetAddress.getLocalHost().getHostName();
                }
                if (this.localHostName == null) {
                        throw new NullPointerError("Null client host name in RPC connection init");
                }
                if (!this.useAuthMemoryStore) {
                  // Search properties for ticket file path, fix for job035376
                  this.ticketsFilePath = this.props.getProperty(PropertyDefs.TICKET_PATH_KEY_SHORT_FORM,
                                                       this.props.getProperty(PropertyDefs.TICKET_PATH_KEY));
                  // Search environment variable
                  if (this.ticketsFilePath == null) {
                  		this.ticketsFilePath = PerforceEnvironment.getP4Tickets();
                  }
                  // Search standard OS location
                  if (this.ticketsFilePath == null) {
                  		this.ticketsFilePath = getDefaultP4TicketsFile();
                  }
                  
                  // Search properties for trust file path
                  this.trustFilePath = this.props.getProperty(PropertyDefs.TRUST_PATH_KEY_SHORT_FORM,
                                                     this.props.getProperty(PropertyDefs.TRUST_PATH_KEY));
                  // Search environment variable
                  if (this.trustFilePath == null) {
                          this.trustFilePath = PerforceEnvironment.getP4Trust();

                  }
                  // Search standard OS location
                  if (this.trustFilePath == null) {
                          this.trustFilePath = getDefaultP4TrustFile();
                  }
                }
                this.serverStats = new ServerStats();
                // Auth file lock handling properties
                this.authFileLockTry = PropertiesHelper.getPropertyAsInt(props,
                		new String[] {PropertyDefs.AUTH_FILE_LOCK_TRY_KEY_SHORT_FORM,
                				PropertyDefs.AUTH_FILE_LOCK_TRY_KEY},
                		AbstractAuthHelper.DEFAULT_LOCK_TRY);
                this.authFileLockDelay = PropertiesHelper.getPropertyAsLong(props,
                		new String[] {PropertyDefs.AUTH_FILE_LOCK_DELAY_KEY_SHORT_FORM,
                				PropertyDefs.AUTH_FILE_LOCK_DELAY_KEY},
                		AbstractAuthHelper.DEFAULT_LOCK_DELAY);
                this.authFileLockWait = PropertiesHelper.getPropertyAsLong(props,
                		new String[] {PropertyDefs.AUTH_FILE_LOCK_WAIT_KEY_SHORT_FORM,
                				PropertyDefs.AUTH_FILE_LOCK_WAIT_KEY},
                		AbstractAuthHelper.DEFAULT_LOCK_WAIT);
        } catch (UnknownHostException uhe) {
                throw new ConfigException("Unable to determine client host name: "
                                + uhe.getLocalizedMessage());
        }

        // Initialize client trust
        clientTrust = new ClientTrust(this);
        
        return status;
}
 
源代码4 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(final String host, final int port, final Properties properties,
                         final UsageOptions opts, final boolean secure)
        throws ConfigException, ConnectionException {

    super.init(host, port, properties, opts, secure);
    try {
        cmdMapArgs = new HashMap<>();
        cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, EMPTY);
        relaxCmdNameValidationChecks = getPropertyAsBoolean(properties,
                RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
        applicationName = RpcPropertyDefs.getProperty(properties, RPC_APPLICATION_NAME_NICK);
        if (isNotBlank(getUsageOptions().getHostName())) {
            localHostName = getUsageOptions().getHostName();
        } else {
            localHostName = InetAddress.getLocalHost().getHostName();
        }

        Validate.notBlank(localHostName,
                "Null or empty client host name in RPC connection init");

        if (!useAuthMemoryStore) {
            // Search properties for ticket file path, fix for job035376
            ticketsFilePath = getPropertyByKeys(props, TICKET_PATH_KEY_SHORT_FORM,
                    TICKET_PATH_KEY);
            // Search environment variable
            if (isBlank(ticketsFilePath)) {
                ticketsFilePath = PerforceEnvironment.getP4Tickets();
            }
            // Search standard OS location
            if (isBlank(ticketsFilePath)) {
                ticketsFilePath = getDefaultP4TicketsFile();
            }

            // Search properties for trust file path
            trustFilePath = getPropertyByKeys(props, TRUST_PATH_KEY_SHORT_FORM, TRUST_PATH_KEY);
            // Search environment variable
            if (isBlank(trustFilePath)) {
                trustFilePath = PerforceEnvironment.getP4Trust();
            }
            // Search standard OS location
            if (isBlank(trustFilePath)) {
                trustFilePath = getDefaultP4TrustFile();
            }
        }
        serverStats = new ServerStats();
        // Auth file lock handling properties
        authFileLockTry = getPropertyAsInt(properties,
                new String[]{AUTH_FILE_LOCK_TRY_KEY_SHORT_FORM, AUTH_FILE_LOCK_TRY_KEY},
                AbstractAuthHelper.DEFAULT_LOCK_TRY);

        authFileLockDelay = getPropertyAsLong(properties,
                new String[]{AUTH_FILE_LOCK_DELAY_KEY_SHORT_FORM, AUTH_FILE_LOCK_DELAY_KEY},
                AbstractAuthHelper.DEFAULT_LOCK_DELAY);

        authFileLockWait = getPropertyAsLong(properties,
                new String[]{AUTH_FILE_LOCK_WAIT_KEY_SHORT_FORM, AUTH_FILE_LOCK_WAIT_KEY},
                AbstractAuthHelper.DEFAULT_LOCK_WAIT);
    } catch (UnknownHostException uhe) {
        throw new ConfigException(
                "Unable to determine client host name: %s" + uhe.getLocalizedMessage());
    }

    // Initialize client trust
    clientTrust = new ClientTrust(this);
    return status;
}
 
源代码5 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(final String host, final int port, final Properties properties,
                         final UsageOptions opts, final boolean secure)
		throws ConfigException, ConnectionException {

	super.init(host, port, properties, opts, secure);
	try {
		cmdMapArgs = new HashMap<>();
		cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, EMPTY);
		relaxCmdNameValidationChecks = getPropertyAsBoolean(properties,
				RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
		applicationName = RpcPropertyDefs.getProperty(properties, RPC_APPLICATION_NAME_NICK);
		if (isNotBlank(getUsageOptions().getHostName())) {
			localHostName = getUsageOptions().getHostName();
		} else {
			localHostName = InetAddress.getLocalHost().getHostName();
		}

		Validate.notBlank(localHostName,
				"Null or empty client host name in RPC connection init");

		if (!useAuthMemoryStore) {
			// Search properties for ticket file path, fix for job035376
			ticketsFilePath = getPropertyByKeys(props, TICKET_PATH_KEY_SHORT_FORM,
					TICKET_PATH_KEY);
			// Search environment variable
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = PerforceEnvironment.getP4Tickets();
			}
			// Search standard OS location
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = getDefaultP4TicketsFile();
			}

			// Search properties for trust file path
			trustFilePath = getPropertyByKeys(props, TRUST_PATH_KEY_SHORT_FORM, TRUST_PATH_KEY);
			// Search environment variable
			if (isBlank(trustFilePath)) {
				trustFilePath = PerforceEnvironment.getP4Trust();
			}
			// Search standard OS location
			if (isBlank(trustFilePath)) {
				trustFilePath = getDefaultP4TrustFile();
			}
		}
		serverStats = new ServerStats();
		// Auth file lock handling properties
		authFileLockTry = getPropertyAsInt(properties,
				new String[]{AUTH_FILE_LOCK_TRY_KEY_SHORT_FORM, AUTH_FILE_LOCK_TRY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_TRY);

		authFileLockDelay = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_DELAY_KEY_SHORT_FORM, AUTH_FILE_LOCK_DELAY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_DELAY);

		authFileLockWait = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_WAIT_KEY_SHORT_FORM, AUTH_FILE_LOCK_WAIT_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_WAIT);
	} catch (UnknownHostException uhe) {
		throw new ConfigException(
				"Unable to determine client host name: %s" + uhe.getLocalizedMessage());
	}

	// Initialize client trust
	clientTrust = new ClientTrust(this);
	return status;
}
 
源代码6 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(final String host, final int port, final Properties properties,
                         final UsageOptions opts, final boolean secure)
		throws ConfigException, ConnectionException {

	super.init(host, port, properties, opts, secure);
	try {
		cmdMapArgs = new HashMap<>();
		cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, EMPTY);
		relaxCmdNameValidationChecks = getPropertyAsBoolean(properties,
				RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
		applicationName = RpcPropertyDefs.getProperty(properties, RPC_APPLICATION_NAME_NICK);
		if (isNotBlank(getUsageOptions().getHostName())) {
			localHostName = getUsageOptions().getHostName();
		} else {
			localHostName = InetAddress.getLocalHost().getHostName();
		}

		Validate.notBlank(localHostName,
				"Null or empty client host name in RPC connection init");

		if (!useAuthMemoryStore) {
			// Search properties for ticket file path, fix for job035376
			ticketsFilePath = getPropertyByKeys(props, TICKET_PATH_KEY_SHORT_FORM,
					TICKET_PATH_KEY);
			// Search environment variable
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = PerforceEnvironment.getP4Tickets();
			}
			// Search standard OS location
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = getDefaultP4TicketsFile();
			}

			// Search properties for trust file path
			trustFilePath = getPropertyByKeys(props, TRUST_PATH_KEY_SHORT_FORM, TRUST_PATH_KEY);
			// Search environment variable
			if (isBlank(trustFilePath)) {
				trustFilePath = PerforceEnvironment.getP4Trust();
			}
			// Search standard OS location
			if (isBlank(trustFilePath)) {
				trustFilePath = getDefaultP4TrustFile();
			}
		}
		serverStats = new ServerStats();
		// Auth file lock handling properties
		authFileLockTry = getPropertyAsInt(properties,
				new String[]{AUTH_FILE_LOCK_TRY_KEY_SHORT_FORM, AUTH_FILE_LOCK_TRY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_TRY);

		authFileLockDelay = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_DELAY_KEY_SHORT_FORM, AUTH_FILE_LOCK_DELAY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_DELAY);

		authFileLockWait = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_WAIT_KEY_SHORT_FORM, AUTH_FILE_LOCK_WAIT_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_WAIT);
	} catch (UnknownHostException uhe) {
           //throw new ConfigException(
           //        "Unable to determine client host name: %s" + uhe.getLocalizedMessage());
           // p4ic4idea: include underlying exception and use clearer exception
           throw new UnknownServerException(
                   "Unable to determine client host name: %s" + uhe.getLocalizedMessage(),
                   uhe);
	}

	// Initialize client trust
	clientTrust = new ClientTrust(this);
	return status;
}
 
源代码7 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(final String host, final int port, final Properties properties,
                         final UsageOptions opts, final boolean secure)
		throws ConfigException, ConnectionException {

	super.init(host, port, properties, opts, secure);
	try {
		cmdMapArgs = new HashMap<>();
		cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, EMPTY);
		relaxCmdNameValidationChecks = getPropertyAsBoolean(properties,
				RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
		applicationName = RpcPropertyDefs.getProperty(properties, RPC_APPLICATION_NAME_NICK);
		if (isNotBlank(getUsageOptions().getHostName())) {
			localHostName = getUsageOptions().getHostName();
		} else {
			localHostName = InetAddress.getLocalHost().getHostName();
		}

		Validate.notBlank(localHostName,
				"Null or empty client host name in RPC connection init");

		if (!useAuthMemoryStore) {
			// Search properties for ticket file path, fix for job035376
			ticketsFilePath = getPropertyByKeys(props, TICKET_PATH_KEY_SHORT_FORM,
					TICKET_PATH_KEY);
			// Search environment variable
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = PerforceEnvironment.getP4Tickets();
			}
			// Search standard OS location
			if (isBlank(ticketsFilePath)) {
				ticketsFilePath = getDefaultP4TicketsFile();
			}

			// Search properties for trust file path
			trustFilePath = getPropertyByKeys(props, TRUST_PATH_KEY_SHORT_FORM, TRUST_PATH_KEY);
			// Search environment variable
			if (isBlank(trustFilePath)) {
				trustFilePath = PerforceEnvironment.getP4Trust();
			}
			// Search standard OS location
			if (isBlank(trustFilePath)) {
				trustFilePath = getDefaultP4TrustFile();
			}
		}
		serverStats = new ServerStats();
		// Auth file lock handling properties
		authFileLockTry = getPropertyAsInt(properties,
				new String[]{AUTH_FILE_LOCK_TRY_KEY_SHORT_FORM, AUTH_FILE_LOCK_TRY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_TRY);

		authFileLockDelay = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_DELAY_KEY_SHORT_FORM, AUTH_FILE_LOCK_DELAY_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_DELAY);

		authFileLockWait = getPropertyAsLong(properties,
				new String[]{AUTH_FILE_LOCK_WAIT_KEY_SHORT_FORM, AUTH_FILE_LOCK_WAIT_KEY},
				AbstractAuthHelper.DEFAULT_LOCK_WAIT);
	} catch (UnknownHostException uhe) {
		throw new ConfigException(
				"Unable to determine client host name: %s" + uhe.getLocalizedMessage());
	}

	// Initialize client trust
	clientTrust = new ClientTrust(this);
	return status;
}
 
源代码8 项目: p4ic4idea   文件: RpcServer.java
public ServerStatus init(String host, int port, Properties props, UsageOptions opts, boolean secure)
                        throws ConfigException, ConnectionException {
        super.init(host, port, props, opts, secure);
        try {
    			this.cmdMapArgs = new HashMap<String, Object>();
    			this.cmdMapArgs.put(ProtocolCommand.RPC_ARGNAME_PROTOCOL_ZTAGS, "");
                this.relaxCmdNameValidationChecks = RpcPropertyDefs.getPropertyAsBoolean(props,
                                                        RpcPropertyDefs.RPC_RELAX_CMD_NAME_CHECKS_NICK, false);
                this.applicationName = RpcPropertyDefs.getProperty(props,
                        								RpcPropertyDefs.RPC_APPLICATION_NAME_NICK, null);
                if (this.getUsageOptions().getHostName() != null) {
                        // This had better reflect reality...
                        this.localHostName = this.getUsageOptions().getHostName();
                } else {
                        this.localHostName = java.net.InetAddress.getLocalHost().getHostName();
                }
                if (this.localHostName == null) {
                        throw new NullPointerError("Null client host name in RPC connection init");
                }
                if (!this.useAuthMemoryStore) {
                  // Search properties for ticket file path, fix for job035376
                  this.ticketsFilePath = this.props.getProperty(PropertyDefs.TICKET_PATH_KEY_SHORT_FORM,
                                                       this.props.getProperty(PropertyDefs.TICKET_PATH_KEY));
                  // Search environment variable
                  if (this.ticketsFilePath == null) {
                  		this.ticketsFilePath = PerforceEnvironment.getP4Tickets();
                  }
                  // Search standard OS location
                  if (this.ticketsFilePath == null) {
                  		this.ticketsFilePath = getDefaultP4TicketsFile();
                  }
                  
                  // Search properties for trust file path
                  this.trustFilePath = this.props.getProperty(PropertyDefs.TRUST_PATH_KEY_SHORT_FORM,
                                                     this.props.getProperty(PropertyDefs.TRUST_PATH_KEY));
                  // Search environment variable
                  if (this.trustFilePath == null) {
                          this.trustFilePath = PerforceEnvironment.getP4Trust();

                  }
                  // Search standard OS location
                  if (this.trustFilePath == null) {
                          this.trustFilePath = getDefaultP4TrustFile();
                  }
                }
                this.serverStats = new ServerStats();
        } catch (UnknownHostException uhe) {
                throw new ConfigException("Unable to determine client host name: "
                                + uhe.getLocalizedMessage());
        }

        // Initialize client trust
        clientTrust = new ClientTrust(this);
        
        return status;
}