Search in sources :

Example 1 with ServerException

use of java.rmi.ServerException in project geode by apache.

the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method executeFunction.

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).setArguments(Boolean.TRUE).execute(function.getId());
        HashMap resultMap = ((HashMap) rc1.getResult());
        assertEquals(3, resultMap.size());
        Iterator mapIterator = resultMap.entrySet().iterator();
        Map.Entry entry = null;
        ArrayList resultListForMember = null;
        while (mapIterator.hasNext()) {
            entry = (Map.Entry) mapIterator.next();
            resultListForMember = (ArrayList) entry.getValue();
            for (Object result : resultListForMember) {
                assertEquals(Boolean.TRUE, result);
            }
        }
    } catch (Exception e) {
        LogWriterUtils.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);
    }
}
Also used : SocketException(java.net.SocketException) ServerException(java.rmi.ServerException) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CacheClosedException(org.apache.geode.cache.CacheClosedException) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) ServerException(java.rmi.ServerException) FunctionException(org.apache.geode.cache.execute.FunctionException) SocketException(java.net.SocketException) CacheClosedException(org.apache.geode.cache.CacheClosedException) SocketTimeoutException(java.net.SocketTimeoutException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) IOException(java.io.IOException) EOFException(java.io.EOFException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Function(org.apache.geode.cache.execute.Function) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) Execution(org.apache.geode.cache.execute.Execution) SocketTimeoutException(java.net.SocketTimeoutException) Iterator(java.util.Iterator) EOFException(java.io.EOFException) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 2 with ServerException

use of java.rmi.ServerException in project geode by apache.

the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method executeFunction.

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).setArguments(Boolean.TRUE).execute(function.getId());
        HashMap resultMap = ((HashMap) rc1.getResult());
        assertEquals(3, resultMap.size());
        Iterator mapIterator = resultMap.entrySet().iterator();
        Map.Entry entry = null;
        DistributedMember key = null;
        ArrayList resultListForMember = null;
        while (mapIterator.hasNext()) {
            entry = (Map.Entry) mapIterator.next();
            key = (DistributedMember) entry.getKey();
            resultListForMember = (ArrayList) entry.getValue();
            for (Object result : resultListForMember) {
                assertEquals(Boolean.TRUE, result);
            }
        }
    } catch (Exception e) {
        LogWriterUtils.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);
    }
}
Also used : SocketException(java.net.SocketException) ServerException(java.rmi.ServerException) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CacheClosedException(org.apache.geode.cache.CacheClosedException) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) ServerException(java.rmi.ServerException) FunctionException(org.apache.geode.cache.execute.FunctionException) SocketException(java.net.SocketException) CacheClosedException(org.apache.geode.cache.CacheClosedException) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException) EOFException(java.io.EOFException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Function(org.apache.geode.cache.execute.Function) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) Execution(org.apache.geode.cache.execute.Execution) SocketTimeoutException(java.net.SocketTimeoutException) Iterator(java.util.Iterator) DistributedMember(org.apache.geode.distributed.DistributedMember) EOFException(java.io.EOFException) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with ServerException

use of java.rmi.ServerException in project cloudstack by apache.

the class NetappManagerImpl method associateLun.

/**
     * This method associates a lun to a particular igroup
     * @param iqn
     * @param iGroup
     * @param lunName
     */
@Override
public String[] associateLun(String guestIqn, String lunName) throws ServerException, InvalidParameterValueException {
    NaElement xi2;
    //get lun id from path
    String[] splitLunName = lunName.split("-");
    String[] returnVal = new String[3];
    if (splitLunName.length != 2)
        throw new InvalidParameterValueException("The lun id is malformed");
    String lunIdStr = splitLunName[1];
    Long lId = new Long(lunIdStr);
    LunVO lun = _lunDao.findById(lId);
    if (lun == null)
        throw new InvalidParameterValueException("Cannot find LUN " + lunName);
    NetappVolumeVO vol = _volumeDao.findById(lun.getVolumeId());
    //assert(vol != null);
    returnVal[0] = lunIdStr;
    returnVal[1] = lun.getTargetIqn();
    returnVal[2] = vol.getIpAddress();
    NaServer s = null;
    try {
        s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());
        if (s_logger.isDebugEnabled())
            s_logger.debug("Request --> associateLun " + ":serverIp:" + vol.getIpAddress());
        //add iqn to the group
        xi2 = new NaElement("igroup-add");
        xi2.addNewChild("force", "true");
        xi2.addNewChild("initiator", guestIqn);
        xi2.addNewChild("initiator-group-name", lunName);
        s.invokeElem(xi2);
        return returnVal;
    } catch (UnknownHostException uhe) {
        s_logger.warn("Unable to associate LUN ", uhe);
        throw new ServerException("Unable to associate LUN", uhe);
    } catch (NaAPIFailedException naf) {
        if (naf.getErrno() == 9008) {
            //initiator group already contains node
            return returnVal;
        }
        s_logger.warn("Unable to associate LUN ", naf);
        throw new ServerException("Unable to associate LUN", naf);
    } catch (NaException nae) {
        s_logger.warn("Unable to associate LUN ", nae);
        throw new ServerException("Unable to associate LUN", nae);
    } catch (IOException ioe) {
        s_logger.warn("Unable to associate LUN ", ioe);
        throw new ServerException("Unable to associate LUN", ioe);
    } finally {
        if (s != null)
            s.close();
    }
}
Also used : ServerException(java.rmi.ServerException) UnknownHostException(java.net.UnknownHostException) NaServer(netapp.manage.NaServer) IOException(java.io.IOException) NaElement(netapp.manage.NaElement) NaAPIFailedException(netapp.manage.NaAPIFailedException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) NaException(netapp.manage.NaException)

Example 4 with ServerException

use of java.rmi.ServerException in project cloudstack by apache.

the class NetappManagerImpl method destroyVolumeOnFiler.

/**
     * This method destroys the volume on netapp filer
     * @param ipAddress -- ip address of filer
     * @param aggrName -- name of containing aggregate
     * @param volName -- name of volume to destroy
     * @throws ResourceInUseException
     * @throws NaException
     * @throws NaAPIFailedException
     */
@Override
@DB
public void destroyVolumeOnFiler(String ipAddress, String aggrName, String volName) throws ServerException, InvalidParameterValueException, ResourceInUseException {
    NaElement xi0;
    NaElement xi1;
    NetappVolumeVO volume = null;
    volume = _volumeDao.findVolume(ipAddress, aggrName, volName);
    if (volume == null) {
        s_logger.warn("The volume does not exist in our system");
        throw new InvalidParameterValueException("The given tuple:" + ipAddress + "," + aggrName + "," + volName + " doesn't exist in our system");
    }
    List<LunVO> lunsOnVol = _lunDao.listLunsByVolId(volume.getId());
    if (lunsOnVol != null && lunsOnVol.size() > 0) {
        s_logger.warn("There are luns on the volume");
        throw new ResourceInUseException("There are luns on the volume");
    }
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    PoolVO pool = _poolDao.findById(volume.getPoolId());
    if (pool == null) {
        throw new InvalidParameterValueException("Failed to find pool for given volume");
    //FIXME: choose a better exception. this is a db integrity exception
    }
    pool = _poolDao.acquireInLockTable(pool.getId());
    if (pool == null) {
        throw new ConcurrentModificationException("Failed to acquire lock on pool " + volume.getPoolId());
    }
    NaServer s = null;
    try {
        s = getServer(volume.getIpAddress(), volume.getUsername(), volume.getPassword());
        //bring the volume down
        xi0 = new NaElement("volume-offline");
        xi0.addNewChild("name", volName);
        s.invokeElem(xi0);
        //now destroy it
        xi1 = new NaElement("volume-destroy");
        xi1.addNewChild("name", volName);
        s.invokeElem(xi1);
        //now delete from our records
        _volumeDao.remove(volume.getId());
        txn.commit();
    } catch (UnknownHostException uhe) {
        s_logger.warn("Unable to delete volume on filer ", uhe);
        throw new ServerException("Unable to delete volume on filer", uhe);
    } catch (NaAPIFailedException naf) {
        s_logger.warn("Unable to delete volume on filer ", naf);
        if (naf.getErrno() == 13040) {
            s_logger.info("Deleting the volume: " + volName);
            _volumeDao.remove(volume.getId());
            txn.commit();
        }
        throw new ServerException("Unable to delete volume on filer", naf);
    } catch (NaException nae) {
        txn.rollback();
        s_logger.warn("Unable to delete volume on filer ", nae);
        throw new ServerException("Unable to delete volume on filer", nae);
    } catch (IOException ioe) {
        txn.rollback();
        s_logger.warn("Unable to delete volume on filer ", ioe);
        throw new ServerException("Unable to delete volume on filer", ioe);
    } finally {
        if (pool != null) {
            _poolDao.releaseFromLockTable(pool.getId());
        }
        if (s != null)
            s.close();
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) ServerException(java.rmi.ServerException) UnknownHostException(java.net.UnknownHostException) NaServer(netapp.manage.NaServer) IOException(java.io.IOException) NaElement(netapp.manage.NaElement) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) NaAPIFailedException(netapp.manage.NaAPIFailedException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceInUseException(com.cloud.exception.ResourceInUseException) NaException(netapp.manage.NaException) DB(com.cloud.utils.db.DB)

Example 5 with ServerException

use of java.rmi.ServerException in project cloudstack by apache.

the class NetappManagerImpl method disassociateLun.

/**
     * 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();
    }
}
Also used : ServerException(java.rmi.ServerException) UnknownHostException(java.net.UnknownHostException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) NaException(netapp.manage.NaException) NaServer(netapp.manage.NaServer) IOException(java.io.IOException) NaElement(netapp.manage.NaElement)

Aggregations

ServerException (java.rmi.ServerException)22 IOException (java.io.IOException)13 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 NaElement (netapp.manage.NaElement)8 NaException (netapp.manage.NaException)8 NaServer (netapp.manage.NaServer)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)6 UnknownHostException (java.net.UnknownHostException)5 DB (com.cloud.utils.db.DB)4 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 NaAPIFailedException (netapp.manage.NaAPIFailedException)4 EOFException (java.io.EOFException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 SocketException (java.net.SocketException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 HashSet (java.util.HashSet)3