Package java.rmi

Examples of java.rmi.ServerException


          selectedVol = _netappAllocator.chooseLeastFullVolumeFromPool(poolName, lunSize);
        }

        if(selectedVol == null)
        {
          throw new ServerException("Could not find a suitable volume to create lun on");
        }

        if(s_logger.isDebugEnabled())
          s_logger.debug("Request --> createLun "+"serverIp:"+selectedVol.getIpAddress());
       
        StringBuilder exportPath = new StringBuilder("/vol/");
        exportPath.append(selectedVol.getVolumeName());
        exportPath.append("/");

        lun = new LunVO(exportPath.toString(), selectedVol.getId(), lunSize, "","");
        lun = _lunDao.persist(lun);
       
        //Lun id created: 6 digits right justified eg. 000045
        String lunIdStr = String.valueOf(lun.getId());
        String zeroStr = "000000";
        int length = lunIdStr.length();
        int offset = 6-length;
        StringBuilder lunIdOnPath = new StringBuilder();
        lunIdOnPath.append(zeroStr.substring(0, offset));
        lunIdOnPath.append(lunIdStr);
        exportPath.append("lun-").append(lunIdOnPath.toString());
       
        lunName.append(lunIdOnPath.toString());
       
        //update lun name
        lun.setLunName(lunName.toString());
        _lunDao.update(lun.getId(), lun);
       
        NaElement xi;
        NaElement xi1;

        long lSizeBytes = 1L*lunSize*1024*1024*1024; //This prevents integer overflow
        Long lunSizeBytes = new Long(lSizeBytes);
       
        s = getServer(selectedVol.getIpAddress(), selectedVol.getUsername(),selectedVol.getPassword());

        //create lun
        xi = new NaElement("lun-create-by-size");
        xi.addNewChild("ostype","linux");
        xi.addNewChild("path",exportPath.toString());
        xi.addNewChild("size", (lunSizeBytes.toString()));
       
        s.invokeElem(xi)

        try
        {
          //now create an igroup
        xi1 = new NaElement("igroup-create");
        xi1.addNewChild("initiator-group-name", lunName .toString());
        xi1.addNewChild("initiator-group-type", "iscsi");
        xi1.addNewChild("os-type", "linux");
        s.invokeElem(xi1);
        }catch(NaAPIFailedException e)
        {
          if(e.getErrno() == 9004)
          {
            //igroup already exists hence no error
            s_logger.warn("Igroup already exists");
          }
        }

        //get target iqn
      NaElement xi4 = new NaElement("iscsi-node-get-name");
      NaElement xo = s.invokeElem(xi4);
      String iqn = xo.getChildContent("node-name");
     
      lun.setTargetIqn(iqn);
      _lunDao.update(lun.getId(), lun);
     
      //create lun mapping
      //now map the lun to the igroup
      NaElement xi3 = new NaElement("lun-map");
      xi3.addNewChild("force", "true");
      xi3.addNewChild("initiator-group", lunName.toString());
      xi3.addNewChild("path", lun.getPath() + lun.getLunName());
     
      xi3.addNewChild("lun-id", lunIdStr);
      s.invokeElem(xi3);
       
        txn.commit();
        //set the result
        result[0] = lunName.toString();//lunname
        result[1] = iqn;//iqn
        result[2] =  selectedVol.getIpAddress();
       
        return result;
       
      }
      catch (NaAPIFailedException naf)
      {
      if(naf.getErrno() == 9023){ //lun is already mapped to this group
        result[0] = lunName.toString();//lunname;
        result[1] = lun.getTargetIqn();//iqn
        result[2] = selectedVol.getIpAddress();
        return result;
      }     
      if(naf.getErrno() == 9024){ //another lun mapped at this group
        result[0] = lunName.toString();//lunname;
        result[1] = lun.getTargetIqn();//iqn
        result[2] = selectedVol.getIpAddress();
        return result;
     
      }
      catch (NaException nae)
      {
        txn.rollback();
        throw new ServerException("Unable to create LUN", nae);
      }
      catch (IOException ioe)
      {
        txn.rollback();
        throw new ServerException("Unable to create LUN", ioe);
      }
      finally
      {
        if (pool != null) {
          _poolDao.releaseFromLockTable(pool.getId());
View Full Code Here


      _lunDao.remove(lun.getId());
      txn.commit();
    } catch(UnknownHostException uhe) {
      txn.rollback();
      s_logger.warn("Failed to delete lun", uhe);
      throw new ServerException("Failed to delete lun", uhe);
    } catch ( IOException ioe) {
      txn.rollback();
      s_logger.warn("Failed to delete lun", ioe);
      throw new ServerException("Failed to delete lun", ioe);
    }catch (NaAPIFailedException naf) {
      if(naf.getErrno() == 9017){//no such group exists excpn
        s_logger.warn("no such group exists excpn 9017 caught in deletelun, continuing with delete");
        _lunDao.remove(lun.getId());
        txn.commit();
      }else if(naf.getErrno() == 9029){//LUN maps for this initiator group exist
        s_logger.warn("LUN maps for this initiator group exist errno 9029 caught in deletelun, continuing with delete");
        _lunDao.remove(lun.getId());
        txn.commit();
      }else{
        txn.rollback();
        s_logger.warn("Failed to delete lun", naf);
        throw new ServerException("Failed to delete lun", naf);
      }

    }
    catch (NaException nae) {
      txn.rollback();
      s_logger.warn("Failed to delete lun", nae);
      throw new ServerException("Failed to delete lun", nae);
    }
    finally{
      if (vol != null) {
        _volumeDao.releaseFromLockTable(vol.getId());
      }
View Full Code Here

      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();
    }
   
View Full Code Here

      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();
    }
View Full Code Here

                params[i] = oin.readRMIObject(paramTypes[i],
                        paramTypes[i].getClassLoader());
            }
        } catch (RemoteException re) {
            // rmi.69=RemoteException occured while unmarshalling arguments
            throw new ServerException(Messages.getString("rmi.69"), re); //$NON-NLS-1$
        } catch (IOException ioe) {
            // rmi.6A=IOException occured while unmarshalling arguments
            throw new UnmarshalException(Messages.getString("rmi.6A"), ioe); //$NON-NLS-1$
        } catch (ClassNotFoundException cnfe) {
            // rmi.6B=ClassNotFoundException occured while unmarshalling arguments
View Full Code Here

        if (t instanceof Error) {
            // rmi.6D=Error occured while remote method invocation
            preparedEx = new ServerError(Messages.getString("rmi.6D"), (Error) t); //$NON-NLS-1$
        } else if (t instanceof RemoteException) {
            // rmi.6E=RemoteException occured while remote method invocation
            preparedEx = new ServerException(Messages.getString("rmi.6E"), //$NON-NLS-1$
                    (RemoteException) t);
        } else {
            preparedEx = t;
        }
        Exception toReturn = (Exception) preparedEx;
View Full Code Here

                    } catch (PrivilegedActionException pae) {
                        IOException ioe = (IOException) pae.getException();

                        if (ioe instanceof RemoteException) {
                            // rmi.77=RemoteException occurred in server thread
                            exToReturn = new ServerException(Messages
                                    .getString("rmi.77"), //$NON-NLS-1$
                                    ioe);
                        } else {
                            throw ioe;
                        }
View Full Code Here

        if (ex instanceof UnknownException) {
            Throwable orig = ((UnknownException)ex).originalEx;
            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;
            }
        }
View Full Code Here

        }

        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;
        }
View Full Code Here

         home = lookupHome("ejbcts2/CalleeSessionHome");
         callee = home.create();
      }
      catch(NamingException e)
      {
         throw new ServerException("Failed to lookup CalleeHome", e);
      }
      catch(CreateException e)
      {
         throw new ServerException("Failed to create Callee", e);
      }

      CalleeData data = callee.simpleCall(false);
      return data;
   }
View Full Code Here

TOP

Related Classes of java.rmi.ServerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.