Examples of IPCException


Examples of org.eclipse.ecf.ipc.IPCException

        actualName = Integer.toString(generateNextActualName());
        break;
      }
     
      default :
        throw new IPCException("Impossible case");
    }

    try
    {
      actualName = Utils.readOrCreate(name, actualName);
      setActualName(actualName);
    }
    catch (IOException e)
    {
      throw new IPCException("Error trying to create or read virtual file for semaphore", e);
    }
  }
View Full Code Here

Examples of org.eclipse.ecf.ipc.IPCException

    SemaphoreNative.increment(result, getHandle());
    result.convertResultCode();

    if (Results.Success != result.result)
    {
      throw new IPCException(result.result.message);
    }
  }
View Full Code Here

Examples of org.eclipse.ecf.ipc.IPCException

    {
      case Success:
        break;

      case Timeout:
        throw new IPCException(Errors.Timeout);

      default:
        throw new IPCException(result.result.message);
    }
  }
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCException

      }
    }
   
    if ( pk == null ){
     
      throw( new IPCException( "Public key missing from '" + arg_str + "'" ));
    }
   
    BuddyPluginBuddy  buddy  = getBuddyFromPublicKey( pk );

    if ( buddy == null ){
     
      throw( new IPCException( "Buddy with public key '" + pk + "' not found" ));
    }
   
    if ( hash == null ){
     
      return( handleUPRSS( connection, buddy, category ));
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCException

 
    throws IPCException
  {
    if ( !buddy.isOnline( true )){
     
      throw( new IPCException( "Buddy isn't online" ));
    }
   
    Map<String,Object>  msg = new HashMap<String, Object>();

    final String if_mod   = connection.getRequestProperty( "If-Modified-Since" );

    try{
      msg.put( "cat", category.getBytes( "UTF-8" ));
                 
      if ( if_mod != null ){
       
        msg.put( "if_mod", if_mod );
      }
     
      // String etag    = connection.getRequestProperty( "If-None-Match" );
         
    }catch( Throwable e ){
     
      Debug.out( e );
    }
   
    final Object[]     result     = { null };
    final AESemaphore  result_sem   = new AESemaphore( "BuddyPlugin:rss" );
       
    final String  etag = buddy.getPublicKey() + "-" + category;
   
    az2_handler.sendAZ2RSSMessage(
      buddy,
      msg,
      new BuddyPluginAZ2TrackerListener()
      {
        public Map
        messageReceived(
          BuddyPluginBuddy  buddy,
          Map          message )
        {
          try{           
            byte[] bytes = (byte[])message.get( "rss" );
         
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
           
            result[0] = bais;
           
            connection.setHeaderField( "ETag", etag );
           
            byte[] b_last_mod = (byte[])message.get( "last_mod" );
           
            if ( b_last_mod != null ){
           
              String  last_mod = new String( b_last_mod, "UTF-8" );
             
              connection.setHeaderField( "Last-Modified", last_mod );
             
              if ( if_mod != null && if_mod.equals( last_mod ) && bytes.length == 0 ){
               
                connection.setResponse( HttpURLConnection.HTTP_NOT_MODIFIED, "Not Modified" );
              }
            }
           
            result_sem.release();
           
          }catch( Throwable e ){
         
            messageFailed( buddy, e );
          }
         
          return( null );
        }
       
        public void
        messageFailed(
          BuddyPluginBuddy  buddy,
          Throwable      cause )
        {         
          result[0] = new IPCException( "Read failed", cause );
         
          result_sem.release();
        }
      });
   
    result_sem.reserve( 60*1000 );
   
    if ( result[0] == null ){
     
      throw( new IPCException( "Timeout" ));
     
    }else if ( result[0] instanceof InputStream ){
     
      return((InputStream)result[0]);
     
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCException

            public void
            messageFailed(
              BuddyPluginBuddy  buddy,
              Throwable      cause )
            {         
              setResult( new IPCException( "Read failed", cause ));
            }
           
            protected void
            setResult(
              Object    obj )
            {
              synchronized( result ){
               
                if ( result_set ){
                 
                  return;
                }
               
                result_set = true;
               
                if ( !( result[0] instanceof byte[] )){
               
                  result[0] = obj;
                }
               
                result_sem.release();
              }
            }
          });
      }catch( Throwable e ){
       
        result[0] = new IPCException( "Buddy torrent get failed", e );
       
        result_sem.release();
      }
    }else{
     
      result[0] = new IPCException( "Buddy is offline" );

      result_sem.release();
    }
   
      // second try and get via magnet
   
    final MagnetPlugin  magnet_plugin = getMagnetPlugin();
   
    if ( magnet_plugin == null ){
   
      synchronized( result ){
       
        if ( result[0] == null ){
         
          result[0] = new IPCException( "Magnet plugin unavailable" );
        }
      }
       
      result_sem.release();
     
    }else{

      new AEThread2( "BuddyPlugin:mag", true )
      {
        private boolean result_set;
       
        public void
        run()
        {
          try{
           
            if ( buddy.isOnline( true )){
             
              Thread.sleep(10*1000);
            }
           
            synchronized( result ){

              if ( result[0] instanceof byte[] ){
               
                setResult( null );
               
                return;
              }
            }
           
            byte[] torrent_data = magnet_plugin.download(
              new MagnetPluginProgressListener()
              {
                public void
                reportSize(
                  long  size )
                {
                }
               
                public void
                reportActivity(
                  String  str )
                {
                  log( "    MagnetDownload: " + str );
                }
               
                public void
                reportCompleteness(
                  int    percent )
                {
                }
               
                public void
                reportContributor(
                  InetSocketAddress  address )
                {
                }
               
                public boolean
                verbose()
                {
                  return( false );
                }
              },
              hash,
              "",
              new InetSocketAddress[0],
              timeout );
           
            if ( torrent_data == null ){
             
              setResult( new IPCException( "Magnet timeout" ));
                         
            }else{         
             
              log( "    torrent downloaded from magnet" );

              setResult( torrent_data );
            }
          }catch( Throwable e ){
           
            setResult( new IPCException( "Magnet get failed", e ));
          }
        }
       
        protected void
        setResult(
          Object    obj )
        {
          synchronized( result ){
           
            if ( result_set ){
             
              return;
            }
           
            result_set = true;
           
            if ( obj != null ){
             
              if (   result[0] == null ||
                  ( obj instanceof byte[] && !( result[0] instanceof byte[] ))){
               
                result[0] = obj;
              }
            }
             
            result_sem.release();
          }
        }
      }.start();
    }
   
    long  start = SystemTime.getMonotonousTime();
       
    if ( result_sem.reserve(timeout )){
     
      if ( !( result[0] instanceof byte[] )){
   
        long  rem = timeout - ( SystemTime.getMonotonousTime() - start );
       
        if ( rem > 0 ){
       
          result_sem.reserve(rem );
        }
      }
    }
   
    if ( result[0] == null ){
     
      log( "    torrent download timeout" );

      throw( new IPCException( "Timeout" ));
     
    }else if ( result[0] instanceof byte[] ){
           
      return( new ByteArrayInputStream((byte[])result[0]));
     
    }else{
     
      IPCException error = (IPCException)result[0];
     
      log( "    torrent downloaded failed: " + Debug.getNestedExceptionMessage( error ));

      throw( error );
    }
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCException

         
          e = e.getCause();
        }
      }
     
      throw new IPCException(e);
    }
  }
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCException

        }
      }
     
      if ( target_use_accessor == null ){
       
        throw( new IPCException( "Plugin has been unloaded" ));
      }
     
      return( target_use_accessor );
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.