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);
}
}
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);
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations