Java 类java.rmi.ServerException 实例源码

项目:OpenJSharp    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:monarch    文件:PRClientServerRegionFunctionExecutionDUnitTest.java   
public static void executeFunction() throws ServerException, InterruptedException {

    Region region = cache.getRegion(PartitionedRegionName);
    assertNotNull(region);
    final HashSet testKeysSet = new HashSet();
    for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
      testKeysSet.add("execKey-" + i);
    }
    DistributedSystem.setThreadsSocketPolicy(false);
    Function function = new TestFunction(true, TEST_FUNCTION2);
    FunctionService.registerFunction(function);
    Execution dataSet = FunctionService.onRegion(region);
    try {
      ResultCollector rc1 =
          dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(function.getId());
      List l = ((List) rc1.getResult());
      LogWriterUtils.getLogWriter().info("Result size : " + l.size());
      assertEquals(3, l.size());

      for (Iterator i = l.iterator(); i.hasNext();) {
        assertEquals(Boolean.TRUE, i.next());
      }
    } catch (CacheClosedException e) {
      // okay - ignore
    }
  }
项目:openjdk-jdk10    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:openjdk9    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:mongoose-base    文件:StorageDriverBase.java   
@Override
public final int put(final List<O> tasks, final int from, final int to)
throws EOFException, ServerException {
    if(!isStarted()) {
        throw new EOFException();
    }
    int i = from;
    O nextTask;
    while(i < to && isStarted()) {
        nextTask = tasks.get(i);
        prepareIoTask(nextTask);
        if(inTasksQueue.offer(tasks.get(i))) {
            i ++;
        } else {
            break;
        }
    }
    final int n = i - from;
    scheduledTaskCount.add(n);
    return n;
}
项目:mongoose-base    文件:StorageDriverBase.java   
@Override
public final int put(final List<O> tasks)
throws EOFException, ServerException {
    if(!isStarted()) {
        throw new EOFException();
    }
    int n = 0;
    for(final O nextIoTask : tasks) {
        if(isStarted()) {
            prepareIoTask(nextIoTask);
            if(inTasksQueue.offer(nextIoTask)) {
                n ++;
            } else {
                break;
            }
        } else {
            break;
        }
    }
    scheduledTaskCount.add(n);
    return n;
}
项目:mongoose-base    文件:StorageDriverBase.java   
protected void prepareIoTask(final O ioTask)
throws ServerException {
    ioTask.reset();
    if(ioTask instanceof DataIoTask) {
        ((DataIoTask) ioTask).getItem().setDataInput(itemDataInput);
    }
    final String dstPath = ioTask.getDstPath();
    final Credential credential = ioTask.getCredential();
    if(credential != null) {
        pathToCredMap.putIfAbsent(dstPath == null ? "" : dstPath, credential);
        if(requestAuthTokenFunc != null) {
            authTokens.computeIfAbsent(credential, requestAuthTokenFunc);
        }
    }
    if(requestNewPathFunc != null) {
        // NOTE: in the distributed mode null dstPath becomes empty one
        if(dstPath != null && !dstPath.isEmpty()) {
            if(null == pathMap.computeIfAbsent(dstPath, requestNewPathFunc)) {
                Loggers.ERR.debug(
                    "Failed to compute the destination path for the I/O task {}", ioTask
                );
                ioTask.setStatus(IoTask.Status.FAIL_UNKNOWN);
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:jdk8u_corba    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:infobip-open-jdk-8    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:openjdk-source-code-learn    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:OLD-OpenJDK8    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:cn1    文件:UnicastServerRef.java   
private Object[] readParams(Method m, RMIObjectInputStream oin)
        throws RemoteException {
    Class[] paramTypes = m.getParameterTypes();
    Object[] params = new Object[paramTypes.length];

    try {
        for (int i = 0; i < paramTypes.length; ++i) {
            params[i] = oin.readRMIObject(paramTypes[i]);
        }
    } catch (RemoteException re) {
        // rmi.69=RemoteException occurred while unmarshalling arguments
        throw new ServerException(Messages.getString("rmi.69"), re); //$NON-NLS-1$
    } catch (IOException ioe) {
        // rmi.6A=IOException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6A"), ioe); //$NON-NLS-1$
    } catch (ClassNotFoundException cnfe) {
        // rmi.6B=ClassNotFoundException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6B"), cnfe); //$NON-NLS-1$
    } catch (Error er) {
        // rmi.6C=Error occurred while unmarshalling arguments
        throw new ServerError(Messages.getString("rmi.6C"), er); //$NON-NLS-1$
    }
    return params;
}
项目:openjdk-orb    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:cloudstack    文件:NetappManagerImpl.java   
/**
 * This method lists all the volumes by pool name
 * @param poolName
 * @return -- volumes in that pool
 */
@Override
public List<NetappVolumeVO> listVolumesOnFiler(String poolName) {

    List<NetappVolumeVO> vols = _volumeDao.listVolumesAscending(poolName);

    for (NetappVolumeVO vol : vols) {
        try {
            String snapScheduleOnFiler = returnSnapshotSchedule(vol);
            vol.setSnapshotPolicy(snapScheduleOnFiler);

        } catch (ServerException e) {
            s_logger.warn("Error trying to get snapshot schedule for volume" + vol.getVolumeName());
        }
    }
    return vols;
}
项目:freeVM    文件:UnicastServerRef.java   
private Object[] readParams(Method m, RMIObjectInputStream oin)
        throws RemoteException {
    Class[] paramTypes = m.getParameterTypes();
    Object[] params = new Object[paramTypes.length];

    try {
        for (int i = 0; i < paramTypes.length; ++i) {
            params[i] = oin.readRMIObject(paramTypes[i]);
        }
    } catch (RemoteException re) {
        // rmi.69=RemoteException occurred while unmarshalling arguments
        throw new ServerException(Messages.getString("rmi.69"), re); //$NON-NLS-1$
    } catch (IOException ioe) {
        // rmi.6A=IOException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6A"), ioe); //$NON-NLS-1$
    } catch (ClassNotFoundException cnfe) {
        // rmi.6B=ClassNotFoundException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6B"), cnfe); //$NON-NLS-1$
    } catch (Error er) {
        // rmi.6C=Error occurred while unmarshalling arguments
        throw new ServerError(Messages.getString("rmi.6C"), er); //$NON-NLS-1$
    }
    return params;
}
项目:freeVM    文件:UnicastServerRef.java   
private Object[] readParams(Method m, RMIObjectInputStream oin)
        throws RemoteException {
    Class[] paramTypes = m.getParameterTypes();
    Object[] params = new Object[paramTypes.length];

    try {
        for (int i = 0; i < paramTypes.length; ++i) {
            params[i] = oin.readRMIObject(paramTypes[i]);
        }
    } catch (RemoteException re) {
        // rmi.69=RemoteException occurred while unmarshalling arguments
        throw new ServerException(Messages.getString("rmi.69"), re); //$NON-NLS-1$
    } catch (IOException ioe) {
        // rmi.6A=IOException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6A"), ioe); //$NON-NLS-1$
    } catch (ClassNotFoundException cnfe) {
        // rmi.6B=ClassNotFoundException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6B"), cnfe); //$NON-NLS-1$
    } catch (Error er) {
        // rmi.6C=Error occurred while unmarshalling arguments
        throw new ServerError(Messages.getString("rmi.6C"), er); //$NON-NLS-1$
    }
    return params;
}
项目:openjdk-icedtea7    文件:Util.java   
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
项目:BaRMIe    文件:IllegalRegistryBind.java   
/*******************
 * Check if the given endpoint can be attacked.
 * 
 * This check is performed by executing a dummy attack against the
 * endpoint and observing the resulting exception.
 * 
 * @param ep An enumerated RMI endpoint.
 * @return True if we can attack it.
 ******************/
public boolean canAttackEndpoint(RMIEndpoint ep) {
    RMIBindExploitProxy proxy = null;
    Registry reg;

    //Execute a dummy attack
    try {
        //Start a bind exploit proxy
        proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, this._dummyPayload);
        proxy.startProxy();

        //Get a proxied RMI registry reference
        reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());

        //Bind a dummy object in an attempt to trigger the vulnerability
        reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
    } catch(BaRMIeException | UnknownHostException | RemoteException | AlreadyBoundException ex) {
        //An up to date RMI registry will, by default, reject the dummy object
        if(ex instanceof ServerException && ex.getCause() != null && ex.getCause() instanceof UnmarshalException && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof InvalidClassException) {
            //Check for "filter status: REJECTED"
            if(ex.getCause().getCause().toString().contains("filter status: REJECTED")) {
                //Test payload was filtered, likely this attack isn't possible
                return false;
            }
        }
    } finally {
        //Stop the proxy
        if(proxy != null) {
            proxy.stopProxy(true);
        }
    }

    //In all other cases we should be able to attack the registry
    return true;
}
项目:BaRMIe    文件:RMIDeserAttack.java   
/*******************
 * Helper method which checks exceptions triggered by a deserialization
 * attacks and attempts to provide additional output to guide the user.
 * 
 * If a ServerException was caused by a ClassNotFoundException then we can
 * safely assume that the chosen gadget chain is not available on the
 * server.
 * 
 * If a ServerError was caused by an IOException which has "Cannot run
 * program" in the message then we can safely assume that the chosen gadget
 * chain is present, but the command wasn't available.
 * 
 * @param ex 
 ******************/
protected final void checkDeserException(Throwable t) {
    boolean responded = false;

    //Check for server-side ClassNotFoundException, indicating that the payload is no use
    if(t instanceof ServerException) {
        while(t.getCause() != null) {
            t = t.getCause();
            if(t instanceof ClassNotFoundException) {
                System.out.println("\n[-] The chosen deserialization payload is not available at the server side.");
                responded = true;
                break;
            }
        }
    }

    //Check for server-side IOException saying that the program could not be run, indicating a successful attack but unavailable target program
    if(t instanceof ServerError) {
        while(t.getCause() != null) {
            t = t.getCause();
            if(t instanceof IOException && t.getMessage().contains("Cannot run program")) {
                System.out.println("\n[+] The attack was successful, however the chosen command was not available.");
                responded = true;
                break;
            }
        }
    }

    //Print generic response if we can't work anything out from the exception
    if(responded == false) {
        System.out.println("\n[~] Attack completed but success could not be verified.");
    }
}
项目:parabuild-ci    文件:ParabuildSoapBindingImpl.java   
/**
 * Helper method to return build service.
 *
 * @param buildID
 * @return return build service.
 */
private BuildService getBuildService(final int buildID) throws ServerException {
  final BuildListService buildListService = ServiceManager.getInstance().getBuildListService();
  final BuildService build = buildListService.getBuild(buildID);
  if (build == null) {
    throw new ServerException("Requested build ID \"" + buildID + "\" not found.");
  }
  return build;
}
项目:gemfirexd-oss    文件:ThriftExceptionUtil.java   
public static SQLException newSQLException(GFXDException gfxde) {
  GFXDExceptionData payload = gfxde.getExceptionData();
  SQLException sqle = newSQLException(payload, gfxde.getCause(),
      gfxde.getServerInfo());
  // since GFXDException is always a wrapper, no need to record the stack
  sqle.setStackTrace(gfxde.getStackTrace());
  // build next exceptions
  List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
  SQLException current = sqle, next;
  if (nextList != null) {
    for (GFXDExceptionData nextData : nextList) {
      // check for server stack indicator
      if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
          nextData.getSqlState())) {
        Throwable cause = sqle;
        while (cause.getCause() != null) {
          cause = cause.getCause();
        }
        cause.initCause(new ServerException(nextData.getReason()));
      }
      else {
        next = newSQLException(nextData, null, null);
        current.setNextException(next);
        current = next;
      }
    }
  }
  return sqle;
}
项目:gemfirexd-oss    文件:PRClientServerRegionFunctionExecutionDUnitTest.java   
public static void executeFunction() throws ServerException,
    InterruptedException {

  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true,TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    ResultCollector rc1 = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(
        function.getId());
    List l = ((List)rc1.getResult());
    getLogWriter().info("Result size : " + l.size());
    assertEquals(3, l.size());

    for (Iterator i = l.iterator(); i.hasNext();) {
      assertEquals(Boolean.TRUE, i.next());
    }
  }
  catch (Exception e) {
    getLogWriter().info("Got an exception : " + e.getMessage());
    assertTrue(e instanceof EOFException || e instanceof SocketException
        || e instanceof SocketTimeoutException
        || e instanceof ServerException || e instanceof IOException
        || e instanceof CacheClosedException);
  }
}
项目:mongoose-base    文件:StorageDriverBase.java   
@Override
public final boolean put(final O task)
throws EOFException, ServerException {
    if(!isStarted()) {
        throw new EOFException();
    }
    prepareIoTask(task);
    if(inTasksQueue.offer(task)) {
        scheduledTaskCount.increment();
        return true;
    } else {
        return false;
    }
}
项目:x-pipe    文件:MigrationServiceImpl.java   
@PostConstruct
private void postConstruct() throws ServerException {
    try {
        migrationShardTblDao = ContainerLoader.getDefaultContainer().lookup(MigrationShardTblDao.class);
    } catch (ComponentLookupException e) {
        throw new ServerException("Cannot construct dao.");
    }
}
项目:codenvy    文件:CreationNotificationSender.java   
public void sendNotification(String userName, String userEmail, boolean withPassword)
    throws IOException, ApiException {
  final URL urlEndpoint = new URL(apiEndpoint);
  final String masterEndpoint = urlEndpoint.getProtocol() + "://" + urlEndpoint.getHost();
  final Template template =
      withPassword
          ? templateWithPassword(masterEndpoint, userEmail, userName)
          : templateWithoutPassword(masterEndpoint, userName);
  final EmailBean emailBean =
      new EmailBean()
          .withBody(doProcessTemplate(template))
          .withFrom(mailFrom)
          .withTo(userEmail)
          .withReplyTo(null)
          .withMimeType(TEXT_HTML);
  if (withPassword) {
    emailBean.setSubject(accountCreatedWithPasswordMailSubject);
  } else {
    emailBean.setSubject(accountCreatedWithoutPasswordMailSubject);
  }

  try {
    mailSender.sendMail(resourceResolver.resolve(emailBean));
  } catch (SendMailException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
项目:codenvy    文件:CreationNotificationSender.java   
private String doProcessTemplate(Template template) throws ServerException {
  try {
    return templateProcessor.process(template);
  } catch (TemplateException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
项目:gemfirexd-oss    文件:ThriftExceptionUtil.java   
public static SQLException newSQLException(GFXDException gfxde) {
  GFXDExceptionData payload = gfxde.getExceptionData();
  SQLException sqle = newSQLException(payload, gfxde.getCause(),
      gfxde.getServerInfo());
  // since GFXDException is always a wrapper, no need to record the stack
  sqle.setStackTrace(gfxde.getStackTrace());
  // build next exceptions
  List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
  SQLException current = sqle, next;
  if (nextList != null) {
    for (GFXDExceptionData nextData : nextList) {
      // check for server stack indicator
      if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
          nextData.getSqlState())) {
        Throwable cause = sqle;
        while (cause.getCause() != null) {
          cause = cause.getCause();
        }
        cause.initCause(new ServerException(nextData.getReason()));
      }
      else {
        next = newSQLException(nextData, null, null);
        current.setNextException(next);
        current = next;
      }
    }
  }
  return sqle;
}
项目:gemfirexd-oss    文件:PRClientServerRegionFunctionExecutionDUnitTest.java   
public static void executeFunction() throws ServerException,
    InterruptedException {

  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true,TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    ResultCollector rc1 = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(
        function.getId());
    List l = ((List)rc1.getResult());
    getLogWriter().info("Result size : " + l.size());
    assertEquals(3, l.size());

    for (Iterator i = l.iterator(); i.hasNext();) {
      assertEquals(Boolean.TRUE, i.next());
    }
  }
  catch (Exception e) {
    getLogWriter().info("Got an exception : " + e.getMessage());
    assertTrue(e instanceof EOFException || e instanceof SocketException
        || e instanceof SocketTimeoutException
        || e instanceof ServerException || e instanceof IOException
        || e instanceof CacheClosedException);
  }
}
项目:cn1    文件:ServerExceptionTest.java   
/**
 * {@link java.rmi.ServerException#ServerException(java.lang.String, java.lang.Exception)}.
 */
public void testServerExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ServerException e = new ServerException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:cn1    文件:ServerExceptionTest.java   
/**
 * {@link java.rmi.ServerException#ServerException(java.lang.String)}.
 */
public void testServerExceptionString() {
    ServerException e = new ServerException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:cloudstack    文件:NetappDefaultAllocatorImpl.java   
@Override
public synchronized NetappVolumeVO chooseLeastFullVolumeFromPool(String poolName, long lunSizeGb) {
    List<NetappVolumeVO> volumesOnPoolAscending = _netappMgr.listVolumesAscending(poolName);

    if (volumesOnPoolAscending == null) {
        //no pools exist in db
        return null;
    }

    long maxAvailable = 0;
    NetappVolumeVO selectedVol = null;
    for (NetappVolumeVO vol : volumesOnPoolAscending) {
        try {
            long availableBytes = _netappMgr.returnAvailableVolumeSize(vol.getVolumeName(), vol.getUsername(), vol.getPassword(), vol.getIpAddress());

            if (lunSizeGb <= bytesToGb(availableBytes) && availableBytes > maxAvailable) {
                maxAvailable = availableBytes; //new max
                selectedVol = vol; //new least loaded vol
            }
        } catch (ServerException se) {
            s_logger.debug("Ignoring failure to obtain volume size for volume " + vol.getVolumeName());
            continue;
        }
    }

    return selectedVol;
}
项目:cloudstack    文件:NetappManagerImpl.java   
/**
 * Utility method to return snapshot schedule for a volume
 * @param vol -- volume for the snapshot schedule creation
 * @return -- the snapshot schedule
 * @throws ServerException
 */
private String returnSnapshotSchedule(NetappVolumeVO vol) throws ServerException {

    NaElement xi = new NaElement("snapshot-get-schedule");
    xi.addNewChild("volume", vol.getVolumeName());
    NaServer s = null;
    try {
        s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());
        NaElement xo = s.invokeElem(xi);
        String weeks = xo.getChildContent("weeks");
        String days = xo.getChildContent("days");
        String hours = xo.getChildContent("hours");
        String minutes = xo.getChildContent("minutes");
        String whichHours = xo.getChildContent("which-hours");
        String whichMinutes = xo.getChildContent("which-minutes");

        StringBuilder sB = new StringBuilder();
        sB.append(weeks)
            .append(" ")
            .append(days)
            .append(" ")
            .append(hours)
            .append("@")
            .append(whichHours)
            .append(" ")
            .append(minutes)
            .append("@")
            .append(whichMinutes);
        return sB.toString();
    } catch (NaException nae) {
        s_logger.warn("Failed to get volume size ", nae);
        throw new ServerException("Failed to get volume size", nae);
    } catch (IOException ioe) {
        s_logger.warn("Failed to get volume size ", ioe);
        throw new ServerException("Failed to get volume size", ioe);
    } finally {
        if (s != null)
            s.close();
    }
}
项目:cloudstack    文件:NetappManagerImpl.java   
/**
 * This method returns the available size on the volume in terms of bytes
 * @param volName -- name of volume
 * @param userName -- username
 * @param password -- password
 * @param serverIp -- ip address of filer
 * @throws UnknownHostException
 * @return-- available size on the volume in terms of bytes; return -1 if volume is offline
 * @throws ServerException
 */
@Override
public long returnAvailableVolumeSize(String volName, String userName, String password, String serverIp) throws ServerException {
    long availableSize = 0;

    NaElement xi = new NaElement("volume-list-info");
    xi.addNewChild("volume", volName);
    NaServer s = null;
    String volumeState = null;
    try {
        s = getServer(serverIp, userName, password);
        NaElement xo = s.invokeElem(xi);
        List volList = xo.getChildByName("volumes").getChildren();
        Iterator volIter = volList.iterator();
        while (volIter.hasNext()) {
            NaElement volInfo = (NaElement)volIter.next();
            availableSize = volInfo.getChildLongValue("size-available", -1);
            volumeState = volInfo.getChildContent("state");
        }

        if (volumeState != null) {
            return volumeState.equalsIgnoreCase("online") ? availableSize : -1; //return -1 if volume is offline
        } else {
            //catch all
            //volume state unreported
            return -1; // as good as volume offline
        }

    } catch (NaException nae) {
        s_logger.warn("Failed to get volume size ", nae);
        throw new ServerException("Failed to get volume size", nae);
    } catch (IOException ioe) {
        s_logger.warn("Failed to get volume size ", ioe);
        throw new ServerException("Failed to get volume size", ioe);
    } finally {
        if (s != null)
            s.close();
    }
}
项目:cloudstack    文件:NetappManagerImpl.java   
/**
 * This method disassociates a lun from the igroup on the filer
 * @param iGroup -- igroup name
 * @param lunName -- lun name
 */
@Override
public void disassociateLun(String iGroup, String lunName) throws ServerException, InvalidParameterValueException {
    NaElement xi;
    LunVO lun = _lunDao.findByName(lunName);

    if (lun == null)
        throw new InvalidParameterValueException("Cannot find LUN " + lunName);

    NetappVolumeVO vol = _volumeDao.findById(lun.getVolumeId());
    NaServer s = null;
    try {
        s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());

        if (s_logger.isDebugEnabled())
            s_logger.debug("Request --> disassociateLun " + ":serverIp:" + vol.getIpAddress());

        xi = new NaElement("igroup-remove");
        xi.addNewChild("force", "true");
        xi.addNewChild("initiator", iGroup);
        xi.addNewChild("initiator-group-name", lunName);
        s.invokeElem(xi);

    } catch (UnknownHostException uhe) {
        throw new ServerException("Failed to disassociate lun", uhe);
    } catch (IOException ioe) {
        throw new ServerException("Failed to disassociate lun", ioe);
    } catch (NaException nae) {
        throw new ServerException("Failed to disassociate lun", nae);
    } finally {
        if (s != null)
            s.close();
    }

}
项目:freeVM    文件:RemoteRegistryTestCase.java   
/**
 * Tries to bind a remote object in a <code>Registry</code> of a 
 * non-local host. 
 * 
 * @throws RemoteException if remote communication with the 
 * registry failed 
 * @throws AlreadyBoundException if the name is already bound 
 */
public void testBind001() throws RemoteException, AlreadyBoundException {

    try {
        reg.bind("echo", exportObj);
        fail("Stub of registry can't chanch registry");
    } catch (ServerException e) {
    }
}
项目:freeVM    文件:RemoteRegistryTestCase.java   
/**
 * This test tries to re-bind a remote object with a same name 
 * in a Registry. 
 * 
 * @throws RemoteException if remote communication with the 
 * registry failed  
 * @throws AlreadyBoundException if the name is already bound 
 */
public void testRebind001() throws RemoteException, MalformedURLException,
        NotBoundException {
    try {
        reg.rebind("echo", exportObj);
        fail("Stub of registry can't chanch registry");
    } catch (ServerException e) {
    }
}
项目:freeVM    文件:RemoteRegistryTestCase.java   
/**
 * This test tries to un-bind remote objects from a non-local 
 * <code>Registry</code>. The object must to be registred.
 * 
 * @throws AccessException if this registry is local and it 
 * denies the caller access to perform this operation 
 * @throws RemoteException if remote communication with the 
 * registry failed  
 * @throws NotBoundException if the name is not currently bound
 */
@SuppressWarnings("unchecked")
public void testUnbind() throws AccessException, RemoteException,
        NotBoundException {
    for (String bindName : reg.list() ) {
        try {
            reg.unbind(bindName);
            fail("Stub of registry can't chanch registry");
        } catch (ServerException e) {
            ITCRemote o =(ITCRemote) reg.lookup(bindName);
            o.getString();
        }
    }
}
项目:freeVM    文件:RemoteRegistryTestCase.java   
/**
 * Tries to bind a remote object in a <code>Registry</code> of a 
 * non-local host. 
 * 
 * @throws RemoteException if remote communication with the 
 * registry failed 
 * @throws AlreadyBoundException if the name is already bound 
 */
public void testBind001() throws RemoteException, AlreadyBoundException {

    try {
        reg.bind("echo", exportObj);
        fail("Stub of registry can't chanch registry");
    } catch (ServerException e) {
    }
}
项目:freeVM    文件:RemoteRegistryTestCase.java   
/**
 * This test tries to re-bind a remote object with a same name 
 * in a Registry. 
 * 
 * @throws RemoteException if remote communication with the 
 * registry failed  
 * @throws AlreadyBoundException if the name is already bound 
 */
public void testRebind001() throws RemoteException, MalformedURLException,
        NotBoundException {
    try {
        reg.rebind("echo", exportObj);
        fail("Stub of registry can't chanch registry");
    } catch (ServerException e) {
    }
}