Class AsyncHttpActor

java.lang.Object
org.nustaq.kontraktor.Actors
org.nustaq.kontraktor.Actor<AsyncHttpActor>
org.nustaq.utils.AsyncHttpActor
All Implemented Interfaces:
Serializable, Executor, org.nustaq.kontraktor.monitoring.Monitorable

public class AsyncHttpActor extends org.nustaq.kontraktor.Actor<AsyncHttpActor>
wraps apache async client in order to simplify concurrent / async crawling / downloads etc. actor-styled
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.nustaq.kontraktor.Actor

    org.nustaq.kontraktor.Actor.ActorReport
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.http.impl.nio.client.CloseableHttpAsyncClient
     
    static boolean
     
    static int
     
    static int
     

    Fields inherited from class org.nustaq.kontraktor.Actor

    __cbQueue, __clientConnection, __connections, __currentDispatcher, __mailbox, __mailboxCapacity, __mbCapacity, __publishTarget, __remoteId, __scheduler, __self, __stopped, __ticketMachine, connection, sender, userData, zzRoutingGCEnabled, zzServerMsgCallback

    Fields inherited from class org.nustaq.kontraktor.Actors

    CONT, DEFAULT_TIMOUT, defaultScheduler, delayedCalls, exec, instance, MAX_EXTERNAL_THREADS_POOL_SIZE, version
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    caches getContent calls for some time.
    org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse>
    get(String url, String... headers)
     
    protected org.apache.http.impl.nio.client.CloseableHttpAsyncClient
     
    org.nustaq.kontraktor.IPromise<String>
    getContent(String url, String... headers)
     
    org.nustaq.kontraktor.IPromise<byte[]>
    getContentBytes(String url, String... headers)
     
    org.nustaq.kontraktor.IPromise<String>
    getContentRaw(boolean bChrome, String url, String... headers)
     
    org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse>
    getRaw(boolean bChrome, String url, String... headers)
     
     
    static void
    main(String[] args)
     
    org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse>
    post(String url, String postData, String... headers)
     
    org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse>
    postWithContext(String url, String postData, org.apache.http.protocol.HttpContext ctx, String... headers)
     
    static byte[]
    readContentBytes(org.apache.http.HttpResponse resp, String enc)
     
    static String
    readContentString(org.apache.http.HttpResponse resp)
     
    void
    setLimits(int maxConPerRoute, int maxConTotal)
    overwrite static limits, WARNING: careful when accessing the singleton
    org.nustaq.kontraktor.IPromise
     
    static byte[]
    unGZip(byte[] barr, int read)
     

    Methods inherited from class org.nustaq.kontraktor.Actor

    __addDeadLetter, __addRemoteConnection, __addStopHandler, __dispatchRemoteCall, __enqueueCall, __getCachedMethod, __removeRemoteConnection, __stop, __stopImpl, __submit, ask, askMsg, asyncstop, checkThread, close, closeCurrentClient, current, cyclic, debounce, delayed, execInThreadPool, execute, getActor, getActorRef, getCallbackSize, getConnections, getCurrentDispatcher, getFactory, getMailboxSize, getQSizes, getReport, getScheduler, getSubMonitorables, getUntypedRef, hasStopped, inside, inThread, isCallbackQPressured, isEmpty, isMailboxPressured, isProxy, isPublished, isRemote, isStopped, ping, router$clientPing, self, serialOn, setServerMsgCallback, stop, stopSafeClose, tell, tellMsg, unpublish, zzkrouterLostClient, zzRoutingRefGC

    Methods inherited from class org.nustaq.kontraktor.Actors

    AddDeadLetter, all, all, all, allMapped, AsActor, AsActor, AsActor, AsActor, AsUntypedActor, awaitAll, awaitAll, awaitAll, awaitAll, complete, complete, DeadLetters, flow, InThread, isComplete, isCont, isError, isErrorOrComplete, isResult, isTimeout, kYield, kYield, promise, race, race, reject, resolve, resolve, stream, SubmitDelayed, yieldCallbacks

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_CONN_PER_ROUTE

      public static int MAX_CONN_PER_ROUTE
    • MAX_CONN_TOTAL

      public static int MAX_CONN_TOTAL
    • asyncHttpClient

      protected org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncHttpClient
    • DUMP_GET

      public static boolean DUMP_GET
  • Constructor Details

    • AsyncHttpActor

      public AsyncHttpActor()
  • Method Details

    • readContentString

      public static String readContentString(org.apache.http.HttpResponse resp) throws IOException
      Throws:
      IOException
    • readContentBytes

      public static byte[] readContentBytes(org.apache.http.HttpResponse resp, String enc) throws IOException
      Throws:
      IOException
    • unGZip

      public static byte[] unGZip(byte[] barr, int read) throws IOException
      Throws:
      IOException
    • getClient

      protected org.apache.http.impl.nio.client.CloseableHttpAsyncClient getClient()
    • getSingleton

      public static AsyncHttpActor getSingleton()
    • sync

      public org.nustaq.kontraktor.IPromise sync()
    • setLimits

      public void setLimits(int maxConPerRoute, int maxConTotal)
      overwrite static limits, WARNING: careful when accessing the singleton
      Parameters:
      maxConPerRoute -
      maxConTotal -
    • enableShortTimeContentCache

      public void enableShortTimeContentCache(long time)
      caches getContent calls for some time. WARNING: IGNORES headers !!
    • getContent

      public org.nustaq.kontraktor.IPromise<String> getContent(String url, String... headers)
    • getContentRaw

      public org.nustaq.kontraktor.IPromise<String> getContentRaw(boolean bChrome, String url, String... headers)
    • getContentBytes

      public org.nustaq.kontraktor.IPromise<byte[]> getContentBytes(String url, String... headers)
    • get

      public org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse> get(String url, String... headers)
    • getRaw

      public org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse> getRaw(boolean bChrome, String url, String... headers)
    • post

      public org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse> post(String url, String postData, String... headers)
    • postWithContext

      public org.nustaq.kontraktor.IPromise<org.apache.http.HttpResponse> postWithContext(String url, String postData, org.apache.http.protocol.HttpContext ctx, String... headers)
    • main

      public static void main(String[] args) throws InterruptedException
      Throws:
      InterruptedException