当前位置: 首页>>代码示例>>Java>>正文


Java ServiceUnavailableException类代码示例

本文整理汇总了Java中javax.naming.ServiceUnavailableException的典型用法代码示例。如果您正苦于以下问题:Java ServiceUnavailableException类的具体用法?Java ServiceUnavailableException怎么用?Java ServiceUnavailableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceUnavailableException类属于javax.naming包,在下文中一共展示了ServiceUnavailableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseSetPatientImmediate3Response

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * Parse a the External Prescriber SetPatientImmediate3Response document, re-throwing errors
 * from the remote web service if necessary.
 * 
 * @param node
 *            The document [fragment] to parse.
 * @throws DOMException
 *             Throws a DOMException if this function is passed a document
 *             it doesn't recognize.
 * @throws IllegalArgumentException
 *             Re-throws an IllegalArgumentException if the remote web
 *             service reports that it didn't receive data in a format it
 *             could recognize.
 * @throws SecurityException
 *             Re-throws a SecurityException if the remote web service
 *             reports a security-related error.
 * @throws Exception
 *             Re-throws an Exception if the remote web service reports an
 *             error that wasn't documented enough in the the External Prescriber
 *             documentation for the programmer to understand what it meant.
 */
public static void parseSetPatientImmediate3Response(Node node)
    throws DOMException, IllegalArgumentException, SecurityException,
    ServiceUnavailableException {
	NodeList childNodes;
	Node child;

	// Die if we're being asked to parse something we don't understand
	if (!node.getNodeName().equals("SetPatientImmediate3Response")) {
		throw new DOMException(
		    DOMException.NOT_SUPPORTED_ERR,
		    "Unable to parse a node of type " + node.getNodeName());
	}

	// Parse this node's child elements
	childNodes = node.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		child = childNodes.item(i);
		if (child.getNodeName().equals("SetPatientImmediate3Result")) {
			SetPatientImmediate3Result
			    .parseSetPatientImmediate3Result(child);
		}
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:45,代码来源:SetPatientImmediate3Response.java

示例2: quotation

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
@RequestMapping("/{bank}/quotation") // bank name format is bank-[1-9]
public Mono<Quotation> quotation( final @PathVariable("bank") String bank, final @RequestParam(value="loanAmount", required=true) Double loanAmount){
    char bankIndex = bank.charAt(5);

    double pseudoInterestRate = bankIndex=='5' ? 0.001d : ((double)bankIndex)/100d;

    if(bankIndex=='2')
        return Mono.error(new ServiceUnavailableException("bank-"+bankIndex+" service is unavailable"));

    if(bankIndex=='3')
        return Mono.delay(Duration.ofMillis(2000)).then(Mono.just(new Quotation("Bank-"+bankIndex,loanAmount)));

    return  Mono.just(new Quotation("Bank-"+bankIndex,loanAmount * pseudoInterestRate));
}
 
开发者ID:noorulhaq,项目名称:reactive.loanbroker.system,代码行数:15,代码来源:BankController.java

示例3: acquireTokenForGraphApi

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
private AuthenticationResult acquireTokenForGraphApi(
        String idToken,
        String tenantId) throws Throwable {
    final ClientCredential credential = new ClientCredential(
            aadAuthFilterProp.getClientId(), aadAuthFilterProp.getClientSecret());
    final UserAssertion assertion = new UserAssertion(idToken);

    AuthenticationResult result = null;
    ExecutorService service = null;
    try {
        service = Executors.newFixedThreadPool(1);
        final AuthenticationContext context = new AuthenticationContext(
                aadAuthFilterProp.getAadSignInUri() + tenantId + "/",
                true,
                service);
        final Future<AuthenticationResult> future = context
                .acquireToken(aadAuthFilterProp.getAadGraphAPIUri(), assertion, credential, null);
        result = future.get();
    } catch (ExecutionException e) {
        throw e.getCause();
    } finally {
        if (service != null) {
            service.shutdown();
        }
    }

    if (result == null) {
        throw new ServiceUnavailableException(
                "unable to acquire on-behalf-of token for client " + aadAuthFilterProp.getClientId());
    }
    return result;
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:33,代码来源:AADAuthenticationFilter.java

示例4: parseGetPrescriptions5Response

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * Parse a the External Prescriber GetPrescriptions5Response document, re-throwing errors
 * from the remote web service if necessary, and returning a list of
 * WSPrescription5 nodes.
 * 
 * @param node
 *            The document [fragment] to parse.
 * @return A list of WSPrescription5 nodes contained in the document.
 * @throws DOMException
 *             Throws a DOMExeption if this function is passed a document
 *             that it doesn't recognize.
 * @throws IllegalArgumentException
 *             Re-throws an IllegalArgumentException if the remote web
 *             service reports that it didn't receive data in a format it
 *             could recognize.
 * @throws SecurityException
 *             Re-throws a SecurityException if the remote web servcice
 *             reports a security-related error.
 * @throws Exception
 *             Re-throws an Exception if the remote web service reports an
 *             error that wasn't documented enough in the the External Prescriber
 *             documentation for the programmer to understand what it meant.
 */
public static List<Node> parseGetPrescriptions5Response(Node node)
    throws DOMException, IllegalArgumentException, SecurityException,
    ServiceUnavailableException {
	// Store a list of WSPrescription5 elements to return
	List<Node> answer = new LinkedList<Node>();
	// Store references to this node's children so we can loop through them
	NodeList childNodes;
	Node child;

	// Die if we're being asked to parse something we don't understand
	if (!node.getNodeName().equals("GetPrescriptions5Response")) {
		throw new DOMException(
		    DOMException.NOT_SUPPORTED_ERR,
		    "Unable to parse a node of type " + node.getNodeName());
	}

	// Parse this node's child elements
	childNodes = node.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		child = childNodes.item(i);
		if (child.getNodeName().equals("GetPrescriptions5Result")) {
			answer.addAll(GetPrescriptions5Result
			    .parseGetPrescriptions5Result(child));
		}
	}

	return answer;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:52,代码来源:GetPrescriptions5Response.java

示例5: getConnector

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
protected JMXConnector getConnector(JMXServiceURL serviceURL, Map<String, ?> environment) throws IOException {
    // Create the JMXCconnectorServer

    JMXConnector connector = null;

    long timeout = System.currentTimeMillis() + (JMX_CLIENT_TIMEOUT_SECS * 1000);

    while (connector == null && System.currentTimeMillis() < timeout) {

        try {
            log.debug("trying to connect to: " + serviceURL);
            connector = JMXConnectorFactory.connect(serviceURL, environment);

            log.debug("connected");
        } catch (IOException e) {

            log.debug("e.getCause(): " + e.getCause().getClass());

            if (!(e.getCause() instanceof ServiceUnavailableException)) {
                log.error("not a ServiceUnavailableException", e);
                break;
            }

            log.debug("ConnectException sleeping..");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                log.debug("InterruptedException:", e1);
            }
        }
    }
    if (connector == null) {

        log.error("failed to get the JMXConnector in time");
    }

    return connector;
}
 
开发者ID:Substeps,项目名称:substeps-framework,代码行数:39,代码来源:SubstepsJMXClient.java

示例6: errorIsRetryable

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
public boolean errorIsRetryable( final Exception e )
{
    if ( e instanceof CommunicationException || e instanceof ServiceUnavailableException )
    {
        final String msgText = e.getMessage();
        if ( msgText != null && !msgText.toLowerCase().contains( "unrecognized extended operation" ) )
        {
            return true;
        }
    }

    return super.errorIsRetryable( e );
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:14,代码来源:JNDIProviderImpl.java

示例7: run

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
@Override
public void run() {
	try{
		long timeIni = System.currentTimeMillis();
		result = pesquisador.pesquisar(this.service, this.xmlParametro);
		if(log.isDebugEnabled()) log.debug("Pesquisa com DLL executada em " + ((System.currentTimeMillis() - timeIni) / 1000) + " segundos.");
	}catch(RemoteAccessException e) {
		if(log.isDebugEnabled()) log.debug("Erro ao pesquisar: " + e.getMessage());
		System.out.flush();
		throw new RuntimeException(new ServiceUnavailableException("Erro ao obter client RMI: " + e.getMessage()));
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:13,代码来源:ValidadorPesquisaOnline.java

示例8: getJMXConnector

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/** Get a JMXConnector to a given host and port, using login and password.
 *
 * @param hostName The host to attempt to connect to.
 * @param jmxPort The port on the host to connect to
 * (a non-negative number).
 * @param login The login name to authenticate as (typically "controlRole"
 * or "monitorRole".
 * @param password The password for JMX access.
 * @return A JMX connector to the given host and port, using default RMI.
 * @throws IOFailure if connecting to JMX fails.
 */
public static JMXConnector getJMXConnector(String hostName,
                                           int jmxPort, final String login,
                                           final String password) {
    ArgumentNotValid.checkNotNullOrEmpty(hostName, "String hostName");
    ArgumentNotValid.checkNotNegative(jmxPort, "int jmxPort");
    ArgumentNotValid.checkNotNullOrEmpty(login, "String login");
    ArgumentNotValid.checkNotNullOrEmpty(password, "String password");
    
    JMXServiceURL rmiurl = getUrl(hostName, jmxPort, -1);
    Map<String, ?> environment = packageCredentials(login, password);
    Throwable lastException;
    int retries = 0;
    final int maxJmxRetries = getMaxTries();
    do {
        try {
            return JMXConnectorFactory.connect(rmiurl, environment);
        } catch (IOException e) {
            lastException = e;
            if (retries < maxJmxRetries && e.getCause() != null
                && (e.getCause() instanceof ServiceUnavailableException 
                      || e.getCause() instanceof SocketTimeoutException)) {
                // Sleep a bit before trying again
                TimeUtils.exponentialBackoffSleep(retries);
                /*  called exponentialBackoffSleep(retries) which used
                    Calendar.MILLISECOND as time unit, which means we only
                    wait an exponential number of milliseconds.
                */
                continue;
            }
            break;
        }
    } while (retries++ < maxJmxRetries);
    throw new IOFailure("Failed to connect to URL " + rmiurl + " after "
                        + retries + " of " + maxJmxRetries
                        + " attempts.\nException type: "
                        + lastException.getCause().getClass().getName(),
                        lastException);
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:50,代码来源:JMXUtils.java

示例9: testRSConnectorServerWhenStopRegionServer

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * This tests to validate the RegionServer's ConnectorServer after unauthorised stopRegionServer
 * call.
 */
@Test(timeout = 180000)
public void testRSConnectorServerWhenStopRegionServer() throws Exception {
  conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
    JMXListener.class.getName() + "," + MyAccessController.class.getName());
  conf.setInt("regionserver.rmi.registry.port", rmiRegistryPort);
  UTIL.startMiniCluster();
  admin = UTIL.getConnection().getAdmin();

  hasAccess = false;
  ServerName serverName = UTIL.getHBaseCluster().getRegionServer(0).getServerName();
  LOG.info("Stopping Region Server...");
  admin.stopRegionServer(serverName.getHostname() + ":" + serverName.getPort());

  // Check whether Region Sever JMX Connector server can be connected
  JMXConnector connector = null;
  try {
    connector = JMXConnectorFactory
        .connect(JMXListener.buildJMXServiceURL(rmiRegistryPort, rmiRegistryPort));
  } catch (IOException e) {
    if (e.getCause() instanceof ServiceUnavailableException) {
      Assert.fail("Can't connect to Region Server ConnectorServer.");
    }
  }
  Assert.assertNotNull("JMXConnector should not be null.", connector);
  connector.close();
}
 
开发者ID:apache,项目名称:hbase,代码行数:31,代码来源:TestJMXConnectorServer.java

示例10: execute

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * Executes the http method specified while protecting the http client with a semaphore. If the maximum number
 * of outstanding requests has been reached it will throw a ServiceUnavailableException. The other exceptions are
 * thrown by the standard http client executeMethod.
 *
 * @return
 * @throws ServiceUnavailableException If the limit of concurrent connections has been reached.
 * @throws IOException                 If an I/O (transport) error occurs. Some transport exceptions cannot be recovered from.
 */
public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException {
    if (semaphore.tryAcquire()) {
        try {
            logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits());
            return HttpUtil.execute(request, timeoutms);
        } finally {
            semaphore.release();
        }
    } else {
        throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests");
    }
}
 
开发者ID:addthis,项目名称:basis,代码行数:22,代码来源:ConstrainedHttpClient.java

示例11: run

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
public void run() {
    try {
        client.execute(new HttpGet("http://www.w3.org"), 10000);
    } catch (ServiceUnavailableException ex) {
        unavailable = true;
    } catch (IOException e) {
    }
}
 
开发者ID:addthis,项目名称:basis,代码行数:9,代码来源:ConstrainedHttpClientTest.java

示例12: announce

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
@Override
public void announce(Model changeSet) {
    Collection<Resource> extResources = getExternalResources(changeSet);

    try {
        for (Resource extResource : extResources) {
            notifyRemoteService(remoteServiceDetector.getRemoteService(extResource), changeSet);
        }
    }
    catch (ServiceUnavailableException e) {
        logger.warn("Remote service unavailable: " +e.getMessage());
    }
}
 
开发者ID:rsine,项目名称:rsine,代码行数:14,代码来源:RemoteNotificationService.java

示例13: isCausedByNetworkIssue

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
@Override
public boolean isCausedByNetworkIssue(CertStoreException e) {
    Throwable t = e.getCause();
    return (t != null && (t instanceof ServiceUnavailableException ||
                          t instanceof CommunicationException));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:LDAPCertStoreHelper.java

示例14: readReply

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * Reads a reply; waits until one is ready.
 */
BerDecoder readReply(LdapRequest ldr)
        throws IOException, NamingException {
    BerDecoder rber;
    boolean waited = false;

    while (((rber = ldr.getReplyBer()) == null) && !waited) {
        try {
            // If socket closed, don't even try
            synchronized (this) {
                if (sock == null) {
                    throw new ServiceUnavailableException(host + ":" + port +
                        "; socket closed");
                }
            }
            synchronized (ldr) {
                // check if condition has changed since our last check
                rber = ldr.getReplyBer();
                if (rber == null) {
                    if (readTimeout > 0) {  // Socket read timeout is specified

                        // will be woken up before readTimeout only if reply is
                        // available
                        ldr.wait(readTimeout);
                        waited = true;
                    } else {
                        // no timeout is set so we wait infinitely until
                        // a response is received
                        // https://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-ldap.html#PROP
                        ldr.wait();
                    }
                } else {
                    break;
                }
            }
        } catch (InterruptedException ex) {
            throw new InterruptedNamingException(
                "Interrupted during LDAP operation");
        }
    }

    if ((rber == null) && waited) {
        abandonRequest(ldr, null);
        throw new NamingException("LDAP response read timed out, timeout used:"
                        + readTimeout + "ms." );

    }
    return rber;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:Connection.java

示例15: parseSetPatientImmediate3Result

import javax.naming.ServiceUnavailableException; //导入依赖的package包/类
/**
 * Parse a the External Prescriber SetPatientImmediate3Result document, re-throwing errors
 * from the remote web service if necessary.
 * 
 * @param node
 *            The document [fragment] to parse.
 * @throws DOMException
 *             Throws a DOMException if this function is passed a document
 *             it doesn't recognize.
 * @throws IllegalArgumentException
 *             Re-throws an IllegalArgumentException if the remote web
 *             service reports that it didn't receive data in a format it
 *             could recognize.
 * @throws SecurityException
 *             Re-throws a SecurityException if the remote web service
 *             reports a security-related error.
 * @throws Exception
 *             Re-throws an Exception if the remote web service reports an
 *             error that wasn't documented enough in the the External Prescriber
 *             documentation for the programmer to understand what it meant.
 */
public static void parseSetPatientImmediate3Result(Node node)
    throws DOMException, IllegalArgumentException, SecurityException,
    ServiceUnavailableException {
	// Store references to this node's children so we can loop through them
	NodeList childNodes;
	Node child;

	// Die if we're being asked to parse something we don't understand
	if (!node.getNodeName().equals("SetPatientImmediate3Result")) {
		throw new DOMException(
		    DOMException.NOT_SUPPORTED_ERR,
		    "Unable to parse a node of type " + node.getNodeName());
	}

	// Parse the node to see if the web service returned errors
	childNodes = node.getChildNodes();
	for (int j = 0; j < childNodes.getLength(); j++) {
		child = childNodes.item(j);
		if (child.getNodeName().equals("ResultCode")) {
			switch (WSPatientResult3.parseString(child.getTextContent())) {
				case ERROR_UNMANAGED:
					throw new ServiceUnavailableException(
					    "The remote system experienced an unhandled error on it's side, but couldn't determine whether it was our fault or not.");
				case ERROR_AUTHENTICATION:
					throw new SecurityException(
					    "The credentials used to send the patient data were not valid.");
				case ERROR_AUTHORIZATION:
					throw new SecurityException(
					    "The user whose credentials were used to send the patient data is not authorized to send patient data.");
				case ERROR_UNAUTHORIZED_CLINIC:
					throw new IllegalArgumentException(
					    "The clinic specified is not valid or has been disabled; or the user whose credentials were used is not registered to request prescription lists on behalf of that clinic.");
				case ERROR_UNKNOWN_CLINIC:
					throw new SecurityException(
					    "The client number specified is not valid or has been disabled.");
				case ERROR_INVALIDLOCALID:
					throw new IllegalArgumentException(
					    "The external prescription service was unable to parse the given locale ID when sending patient data.");
				case ERROR_NONSECUREACCESS:
					throw new SecurityException(
					    "The transport method used to send the patient data was not secure, so the request was rejected.");
			}
		}
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:67,代码来源:SetPatientImmediate3Result.java


注:本文中的javax.naming.ServiceUnavailableException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。