Giter Club home page Giter Club logo

Comments (13)

baifan avatar baifan commented on May 24, 2024

hi,
is the issue in the plan?

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan yes. I feel this is an important feature. When you feel you will need this (ETA)? I will try to make the change accordingly

from parallec.

baifan avatar baifan commented on May 24, 2024

@jeffpeiyt I want to use it in the monitoring system, verify the inside service is available and get the service stats. Request format is 'http://ip:port/path?param' , as follows

http://192.168.1.23:9000/check?parm=1
http://192.168.1.24:9000/check?parm=1

Look forward to it as soon as possible.

Thanks~

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan , in your example they all have the same port 9000, if that is the case, it has been supported already. please check here for more details

from parallec.

baifan avatar baifan commented on May 24, 2024

@jeffpeiyt
Iā€˜m sorry to mislead you. Two services may in one physical server, and the ports are not same.

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan just to confirm, it is a mixture of different hosts, and same host with diff ports and also diff APIs?

such as

host1:9000/api1;
host2:9000/api1;
host3:8000/api2;
host3:9000/api2;

from parallec.

baifan avatar baifan commented on May 24, 2024

@jeffpeiyt
In my case, they have the same API, same header, but diff hosts and diff ports.

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan Thanks for your clarification. I will first try to address this situation and keep you posted. Hopefully I will get most done by this weekend.

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan Just done this feature. Looks like it has been working, pending more thorough tests and documentation. I will commit once the tests pass. Please let me know any more questions you have.

here is the test to call 2 ports on 2 target hosts with same API. Rely on the website portquiz.net able to serve at 8080 port.

the key is .setHttpPortReplaceable("$PORT") with replacement with port in strings.

Test as follows
requests to

http://www.jeffpei.com:80/job_b.html  //should return 200 OK
http://portquiz.net:8080/job_b.html  //should return 404 not found
    /**
     * TODO 20160721 git issue #25
     * different requests to different ports  
     * http://www.jeffpei.com:80/job_b.html http://portquiz.net:8080/job_b.html
     */
    @Test
    public void hitWebsitesMinTargetHostSpecificPortReplacement() {

        Map<String, StrStrMap> replacementVarMapNodeSpecific = new HashMap<String, StrStrMap>();
        replacementVarMapNodeSpecific.put("portquiz.net",
                new StrStrMap().addPair("PORT", "8080"));
        replacementVarMapNodeSpecific.put("www.jeffpei.com",
                new StrStrMap().addPair("PORT", "80"));

        pc.prepareHttpGet("/job_b.html")
                .setHttpPortReplaceable("$PORT")
                .setConcurrency(1700)
                .setTargetHostsFromString(
                        "portquiz.net www.jeffpei.com")
                .setReplacementVarMapNodeSpecific(replacementVarMapNodeSpecific)
                .execute(new ParallecResponseHandler() {
                    @Override
                    public void onCompleted(ResponseOnSingleTask res,
                            Map<String, Object> responseContext) {
                        if(res.getRequest().getHost()=="portquiz.net"){
                            Assert.assertTrue( 
                                    res.getStatusCodeInt()==404);
                        }else if(res.getRequest().getHost()=="www.jeffpei.com"){
                            Assert.assertTrue(
                                    res.getStatusCodeInt()==200);
                        }
                        logger.info(res.toString());
                    }
                });

    }

Logs

23:41:05.971 [main] INFO  i.p.c.t.ParallelTaskManager - Initialized ParallelTaskManager...
23:41:05.978 [main] INFO  i.p.c.r.AsyncHttpClientFactoryEmbed - FastClient: ningFastClientConnectionTimeoutMillis: 4000
23:41:05.979 [main] INFO  i.p.c.r.AsyncHttpClientFactoryEmbed - FastClient: ningFastClientRequestTimeoutMillis: 14000
23:41:06.009 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.010 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.012 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.013 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.100 [main] INFO  i.p.c.ParallelClient - Initialing Parallel Client Resources: actor system, HttpClientStore, Task Manager ....
23:41:06.449 [main] INFO  i.p.c.r.AsyncHttpClientFactoryEmbed - FastClient: ningFastClientConnectionTimeoutMillis: 4000
23:41:06.449 [main] INFO  i.p.c.r.AsyncHttpClientFactoryEmbed - FastClient: ningFastClientRequestTimeoutMillis: 14000
23:41:06.449 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.449 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.450 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.450 [main] INFO  c.n.h.c.p.n.NettyAsyncHttpProvider - Number of application's worked threads is 0
23:41:06.451 [main] INFO  i.p.c.ParallelClient - Parallel Client Resources has been initialized.
23:41:06.457 [main] INFO  i.p.c.ParallelTaskBuilder - Initialized task builder with default config
23:41:06.457 [main] INFO  i.p.c.u.PcTargetHostsUtils - Target hosts size : 2
23:41:06.458 [main] INFO  i.p.c.ParallelTaskBuilder - Set requestReplacementType as {}TARGET_HOST_SPECIFIC_VAR_REPLACEMENT
23:41:06.460 [main] INFO  i.p.c.ParallelTaskBuilder - ***********START_PARALLEL_HTTP_TASK_PT_2_20160721234106460_7f49fd80-7f4***********
23:41:06.460 [main] INFO  i.p.c.ParallelTask - USE DEFAULT HTTP PROTOCOL: Missing Protocol HTTP/HTTPS. SET protocol as default HTTP
23:41:06.460 [main] INFO  i.p.c.b.HttpMeta - USE DEFAULT HTTP CLIENT: Did not set special asyncHttpClient, will use the current default one: EMBED_FAST
23:41:06.460 [main] INFO  i.p.c.b.HttpMeta - USE DEFAULT EMPTY HEADER: Did not specify HTTP header. Will use empty header. Use .setHeaders to add headers
23:41:06.461 [main] INFO  i.p.c.ParallelTaskBuilder - Disabled CapacityAwareTaskScheduler. Immediately execute task PT_2_20160721234106460_7f49fd80-7f4 
23:41:06.461 [main] INFO  i.p.c.ParallelTaskBuilder - Executing task PT_2_20160721234106460_7f49fd80-7f4 in SYNC mode...  
23:41:06.461 [Thread-1] INFO  i.p.c.t.ParallelTaskManager - Added task PT_2_20160721234106460_7f49fd80-7f4 to the running inprogress map...
23:41:06.462 [Thread-1] INFO  i.p.c.t.ParallelTaskManager - !!STARTED sendAgentCommandToManager : PT_2_20160721234106460_7f49fd80-7f4 at 2016-07-21 23:41:06.462-0700
23:41:06.465 [ParallecActorSystem-akka.actor.default-dispatcher-3] INFO  i.p.c.a.ExecutionManager - parallec task state : IN_PROGRESS
23:41:06.465 [ParallecActorSystem-akka.actor.default-dispatcher-3] INFO  i.p.c.a.ExecutionManager - Before Safety Check: total entry count: 2
23:41:06.465 [ParallecActorSystem-akka.actor.default-dispatcher-3] INFO  i.p.c.a.ExecutionManager - After Safety Check: total entry count in nodeDataMapValidSafe: 2
23:41:06.465 [ParallecActorSystem-akka.actor.default-dispatcher-3] INFO  i.p.c.a.ExecutionManager - !Obtain command request for target host meta id THM_2_20160721234106460_511d3eca-262  with count: 2
23:41:06.472 [ParallecActorSystem-akka.actor.default-dispatcher-5] INFO  i.p.c.a.AssistantExecutionManager - Now finished sending all needed messages. Done job of ASST Manager at 2016.07.21.23.41.06.472-0700
23:41:06.839 [ParallecActorSystem-akka.actor.default-dispatcher-5] INFO  i.p.c.a.ExecutionManager - 
[1]__RESP_RECV_IN_MGR 1 (+1) / 2 (50.000%)  AFT 0.374 S @ portquiz.net @ 2016.07.21.23.41.06.838-0700 , TaskID : 7f49fd80-7f4 , CODE: 404 Not Found, RESP_BRIEF: <!DOCTYPE HTML PUBLIC "-//IETF// 
23:41:06.840 [ParallecActorSystem-akka.actor.default-dispatcher-5] INFO  i.p.c.TestBase - SingleTaskResponse [request=TaskRequest [actorMaxOperationTimeoutSec=15, resourcePath=/job_b.html, requestContent=, httpMethod=GET, pollable=false, httpHeaderMap={}, protocol=http, host=portquiz.net, hostUniform=null, port=8080, sshMeta=null], responseContent=<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /job_b.html was not found on this server.</p>
</body></html>
, receiveTime=2016.07.21.23.41.06.837-0700, receiveTimeInManager=2016.07.21.23.41.06.837-0700, error=false, errorMessage=null, stackTrace=null, statusCode=404 Not Found, operationTimeMillis=365, pollingHistoryMap={}]
23:41:07.053 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - 
[2]__RESP_RECV_IN_MGR 2 (+0) / 2 (100.00%)  AFT 0.589 S @ www.jeffpei.com @ 2016.07.21.23.41.07.053-0700 , TaskID : 7f49fd80-7f4 , CODE: 200 OK, RESP_BRIEF: <!DOCTYPE html>
<!-- saved from  
23:41:07.053 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.TestBase - SingleTaskResponse [request=TaskRequest [actorMaxOperationTimeoutSec=15, resourcePath=/job_b.html, requestContent=, httpMethod=GET, pollable=false, httpHeaderMap={}, protocol=http, host=www.jeffpei.com, hostUniform=null, port=80, sshMeta=null], responseContent=<!DOCTYPE html>
<!-- saved from url=(0033)http://www.jeffpei.com/job_b.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body>

<h1>My Job Status</h1>

<table border="1">
    <tbody><tr>
        <td>JobID</td>
        <td>51243</td>
    </tr>
                <tr>
        <td>JobProgress</td>
        <td>80%</td>
    </tr>
</tbody></table>
                <h4>A demo page to show a sample server-based job status page for use cases by REST Commander.</h4>


</body></html>, receiveTime=2016.07.21.23.41.07.052-0700, receiveTimeInManager=2016.07.21.23.41.07.053-0700, error=false, errorMessage=null, stackTrace=null, statusCode=200 OK, operationTimeMillis=582, pollingHistoryMap={}]
23:41:07.054 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - task.state : COMPLETED_WITHOUT_ERROR
23:41:07.054 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - task.totalJobNumActual : 2 InitCount: 2
23:41:07.054 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - task.response received Num 2 
23:41:07.054 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - SUCCESSFUL GOT ON ALL RESPONSES: Received all the expected messages. Count matches: 2 at time: 2016.07.21.23.41.07.054-0700
23:41:07.054 [ParallecActorSystem-akka.actor.default-dispatcher-2] INFO  i.p.c.a.ExecutionManager - 
Time taken to get all responses back : 0.59 secs
23:41:07.055 [Thread-1] INFO  i.p.c.t.ParallelTaskManager - !!COMPLETED sendTaskToExecutionManager : PT_2_20160721234106460_7f49fd80-7f4 at 2016-07-21 23:41:07.054-0700          GenericResponseMap in future size: 2
23:41:07.055 [Thread-1] INFO  i.p.c.t.ParallelTaskManager - Removed task PT_2_20160721234106460_7f49fd80-7f4 from the running inprogress map... . This task should be garbage collected if there are no other pointers.
23:41:07.467 [main] INFO  i.p.c.ParallelTaskBuilder - ***********FINISH_PARALLEL_HTTP_TASK_PT_2_20160721234106460_7f49fd80-7f4***********
23:41:07.469 [main] INFO  i.p.c.ParallelClient - Releasing all ParallelClient resources... 
23:41:07.469 [main] INFO  i.p.c.a.ActorConfig - shutting down actor system...
23:41:07.488 [main] INFO  i.p.c.a.ActorConfig - Actor system has been shut down.
23:41:07.490 [main] INFO  i.p.c.ParallelClient - Have released all ParallelClient resources (actor system + async+sync http client + task queue)
Now safe to stop your application.

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan this feature has been released in http://search.maven.org/#artifactdetails|io.parallec|parallec-core|0.9.4-beta| . could you please try with the example? Please let me know if this works with the example?

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan please let me know your feedback. I will close the issue for now. Feel free to reopen it for more questions.

from parallec.

baifan avatar baifan commented on May 24, 2024

@jeffpeiyt
Sorry for the late reply. This feature can solve this issue, thank you very much.
But This API looks a bit complicated.

from parallec.

jeffpeiyt avatar jeffpeiyt commented on May 24, 2024

@baifan thanks for the confirmation.

The API use the more generic Map<String, StrStrMap> to replace, yes need to use String type and looks a bit complicated, however, can be more universal and write the same time as having replacing other variables too

 replacementVarMapNodeSpecific.put("portquiz.net",
                new StrStrMap().addPair("PORT", "8080"));
        replacementVarMapNodeSpecific.put("www.jeffpei.com",
                new StrStrMap().addPair("PORT", "80"));

from parallec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.