Threading on different servers

Hi,
I have a single client that sends same data parameters to two servers. It needs each server to complete a few runs and report the results. At the same time the client has an overall target to accomplish, say 200 runs. Servers may execute a single batch of 20 runs at a time. So it starts off with allocating 20 runs each to both servers which get busy immediately. Whichever server sends in the results first or gets free, needs to be allocated another 20 runs. This needs to happen till all 200 runs are completed.
I have written two threads calling the same constructor yet passing different IP Addresses into the constructor. Run method basically has the same code for each thread.
The problem: I start both the threads at the same time, but how do I check which server finished its batch (Will Thread.getState() help resolve the problem?) and then how do I allocate the next lot of 20 runs? Both the threads are running and there seems no way to find out which one finished first batch.
Thanks.

Hello Javajockey,
implementing Runnable is good practice - it makes the code a little more general:
Worker.java (revised)
class Worker extends Thread {
     private final Queue<Runnable> queue;
     Worker(Queue<Runnable> queue) {
          this.queue = queue;
          this.setDaemon(true);
     @Override
     public void run() {
          while (true) {
               try {
                    Runnable runnable = queue.getNext();
                    runnable.run();
               } catch (RuntimeException e) {
                    // in case the run() method throws an
                    // exception. if you don't catch it, the thread
                    // will be terminated and you lose a
                    // worker without wanting to.
                    // you should implement some logging mechanism
                    // ( even a System.out.println(...); will do.
                    // see: http://www.javapractices.com/Topic16.cjp )
               } /* finally {
                    // this finally block is now obsolete
                    // unless you accumulate resources
                    // somewhere in the obove try statement
}Now let's just revise the code snippet from befor:
Queue<Runnable> queue = new Queue<Runnable>();
new Worker(queue).start(); // worker one
new Worker(queue).start(); // worker two
// I don't know where you get the parameters from,
// but you'll figure it out..
queue.add(new TSP(port1, port2, ip));I noticed, that I forgot to start() the workers. That's probably why you did not get it to work.. silly me!
I commented it a little more detailed anyway.
Hopefully that's all you need. The best of luck! ;)
With kind regards
Ben

Similar Messages

  • Copying variants between different servers

    Hello All ,
    There are 2 servers MSAP and 1SAP ,1SAP is the new implementation that we are doing .MSAP is their previous system .
    I have to copy a program from MSAP to 1SAP ,but there are many variants in that .Is there any method i can copy variants between 2 different servers?? coz there are lot of variants in the existing system .
    Regards ,
    Hemanth .

    Hi,
    Refer FM's:-
    RS_VARIANT_CONTENTS or
    RS_VARIANT_ADD or
    RS_VARIANT_CHANGE.
    Also you can refer thread:-
    Re: Copying Variants
    Hope this helps you.
    Regards,
    Tarun

  • Logical systems assignment when SRM and ECC are on 2 different servers

    Hi SRM guru's,
    What is the standard practice for Logical system creation and assignment when  ECC and SRM are on 2 different servers.
    I could not able to find which i created a logical system  in SRM server which i created in ECC
    Same for the ECC also.
    how do i assign logical system of SRM to ECC
    vice versa.
    your prompt response is appreciated.
    Regards

    Hi Sai,
    Logical System Naming/Creation procedure is not dependent on the servers but it is just a logical representation of a system.
    As you are trying to name logical systems for ECC & SRM, please follow the below procedure which is usually recommeded by SAP and followed.
    Logical System : <SID>CLNT<Client Number>
    For Example if you have a client 300 in system DE0 (also called SID), the logical system name will be DE0CLNT300. And it will be same for SRM system.
    You can refer the below document which eplains the creation of logical system and RFC destinations etc
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFAALEQS/CABFAALEQS.pdf
    Note: Only while configuring the RFC Destination, the servers will play a crucial role.
    Regards
    Kathirvel

  • I do not see where to enter IP addresses in the Open VPN setup. Also, how can I set it up so that I can choose different servers in the same way as I can currently choose them with my VPN app but for PPTP?

    I think I have it working on my iPhone 5. But, I do not see how I can control the exit point that I would like for the VPN. Are all the exit points shown in the VPN setting now going to work with Open VPN, or do they remain PPTP? If I am reading correctly, they look like they remain PPTP. If I cannot control the exit point for open VPN, which exit point is the default in the profile you provided me?I note that Open VPN Connect does not work with any of the new 64 bit devices like the iPhone 5S, the iPad Air, and the new iPad MIni. Is there any chance that you guys will come up with an update for your app so that open VPN can be made to work on all iOS devices? That would be nice, particularly if the Open VPN Connect app does not give me a choice of exit points.Thanks,
    I do not see where to enter IP addresses in the Open VPN setup. Also, how can I set it up so that I can choose different servers in the same way as I can currently choose them with my VPN app but for PPTP?
    Just a quick note to tell you that Open VPN has updated their app so that it is compatible with 64 bit ARM devices like the iPhone 5S, the iPad Air, and the iPad Mini Retina.That does not resolve the problem of how to easily choose among the various possibilities for the exit server. We need to find an easy way to choose.

    Thank you for trying the new Firefox. I'm sorry that you’re unhappy with the new design.
    I understand your frustration and surprise at the removal of these features but I can't undo these changes. I'm just a support volunteer and I do not work for Mozilla. But you can send any feedback about these changes to http://input.mozilla.org/feedback. Firefox developers collect data submitted through there then present it at the weekly Firefox meeting
    I recommend you try to adjust to 29 and see if you can't make it work for you before you downgrade to a less secure and soon outdated version of Firefox.
    Here are a few suggestions for restoring the old design. I hope you’ll find one that works for you:
    *Use the [https://addons.mozilla.org/en-US/firefox/addon/classicthemerestorer/ Classic Theme Restorer] to bring back the old design. Learn more here: [[How to make the new Firefox look like the old Firefox]]
    *Use the [https://addons.mozilla.org/en-US/firefox/addon/the-addon-bar/ Add-on Bar Restored] to bring back the add-on bar. Learn more here: [[What happened to the Add-on Bar?]]

  • Setting mail with Cox (or other services with different servers for pop and smtp)

    My Cox mail account uses different servers for pop and smtp (my personal ISP 1&1 does too).
    The mail applet on my Blackberry Curve 8330 with Verizon does not allow to define different servers for pop and smtp, and further, for SSL smtp mail, the port is fixed at 995 and cannot be changed, while Cox (and 1&1) want to use 587 or something like that.
    As a result, I can only receive mail with these services.
    I also have yahoo mail, which works fine, so I can send mail with it and it is not a life-and-death situation, but I would like to be able to just reply to email sent to my Cox address.
    I called Verizon and they said BlackBerry provides the mail access through their servers and the applet, so there is nothing they can do.
    Is there a way to set it such that I can not only receive but also send mail through either of these services?
    Thanks in advance,
    Didier
    PS: Other than that, the Curve on Verizon rocks!!! so much better down here than AT&T it's not even funny.

    OK, thank you for the input.
    The problem I have with this solution is like the one I have now using yahoo.
    There are 2 problems:
    1) mailing lists want the mail to come from the account that is subscribed, so if the cox account is subscribed, I can't contribute from the blackberry, and if the blackberry account is subscribed, I don't get my mail in Outlook. Neither is good for me.
    2) people who send me mail to the Cox account and get replies from me from the blackberry continue responding to the account that can send from the blackberry (not Cox), and from that point on I do not have that mail on the computer.
    The issue of having two copies is no big deal, I just delete the mail I do not need. I would rather have two than none.
    Really, Blackberry should modify the email service so that they directly support mail systems like those of Cox and 1&1. I am sure there are others. They should also allow the use of another port for SSL than 995. I have not seen anyone using 995 for SSL.
    Until recently, I had a BB provided by my employer, and we had a BES, and that worked really well. I would like to emulate as much of that functionality as possible without having to pay somebody another $10 or $20 a month just for the priviledge of having an account on a private BES server.
    Anyway, thanks for the exchange and suggestions.
    Didier

  • What are the entities that can be re-used in different servers, SI App, SI instance? And how?

    Greetings,
    What are the entities that can be re-used in different servers, SI App, SI instance? And how?
    e.g. can I use a deployed IQStreamable@app1  into app2?
    can I use a deployed observable/app1/siInstance1/Server1 into another query/app3/siInstance3/server2?
    On the presentation titled "04 – Installing, Deploying and Maintaining the SQL Server 2008 R2 StreamInsight Runtime Engine" with file name SQL10R2UPD05-DECK-04.pptx on ecn.channel9.msdn.com/o9/learn/SQL2008R2TrainingKit/Presentations/SQL10R2UPD05-DECK-04/SQL10R2UPD05-DECK-04.pptx
    It is mentioned one of the deployment option is "Deployment: Standalone Server"
    and it mention the following:
    "Use this option for the following scenarios:
    - Metadata objects need to be shared between applications
      - Event Types
      - Adapter Types
      - Query Templates
    - A data source registered with the server provides an event stream for another existing application"
    Could you please provide good example that explain the above statement?
    Cheers, Muhammad

    First, that statement - and those materials - refer to the "legacy" StreamInsight query/adapter model. They do not refer to how things work with the Reactive model introduced in version 2.1. Specifically, it talks about Dynamic Query Composition (DQC).
    You cannot use a deployed Observable in another instance of StreamInsight. You may be able to use them across applications in the same instance - off the top of my head, I'm not sure. I'm getting ready to get on a plane but will take a look at it later.
    Typically, however, applications act as containers (comparable to .NET AppDomains) so I don't think that you'd be able to do this easily. That said, the code and assemblies
    can be reused across multiple instances/applications. You would have separate instances of the classes involved but you would be able to reuse the query logic. That's a common use case.
    Can you be more specific about your use case and what you are trying to accomplish here? It's possible that there are alternative ways to do what you are trying to do.
    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)
    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

  • Mail: email retrieval from 2 different servers

    I retrieve emails to MAIL for my 2 email addresses from 2 different servers (gmail and 'workspace'). I try to keep the email on the servers to a minimum by deleting emails, but I want all the emails to stay in "Mail" on my Macbook pro.  When I delete email on the gmail server and then 'check mail' in Mail, if it's not on the gmail server, it gets deleted in Mail.  Under 'preferences:accounts:advanced' I've selected 'all messages and their attachments' under 'keep messages for offline viewing'.  I thought this would preserve all emails in Mail, but it doesn't.  What should I do to make sure all the emails I want to stay in Mail, stay there regardless of whether they are still on the servers or not?  Thanks.

    try, like this
    SQL> select name from v$database;
    NAME
    DBDEMO
    SQL> create user testing identified by passwd;
    User created.
    SQL> grant connect,resource to testing;
    Grant succeeded.
    SQL> conn testing/passwd;
    Connected.
    SQL> create table test_tb (id number);
    Table created.
    SQL> insert into test_tb values(123);
    1 row created.
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select count(*) from test_tb;
      COUNT(*)
             2
    SQL>
    on dblink created machine:-
    SQL> select name from v$database;
    NAME
    DB2
    SQL> create user nic identified by nic;
    User created.
    SQL> grant connect,resource, create database link to nic;
    Grant succeeded.
    SQL> conn nic/nic;
    Connected.
    SQL> create database link test_db_link connect to testing identified by passwd using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dbdemo)))
      2  ';
    Database link created.
    SQL> select count(*) from test_tb@test_db_link;
      COUNT(*)
             2
    SQL>

  • CFLOGIN works, but not simultaneously on different servers/broswers

    I'm using CFLOGIN with application.cfc which works great when I test it - I'll call it login session A in browser window 1.
    When I simultaneously log into the same app on a different server with a different username (login session B in browser window 2), I can't login - unless I log out out of session A/browser window 1 first. Something in my new code is preventing me from logging into my app more than one time, even when the apps are on separate servers and I'm using different usernames.
    We have the same app on various servers (test/development/production), and I used to be able to login on 2-3 browsers or servers at a time - and I never had a problem until recently when I made some changes to the application.cfc and login code.
    I updated the code because before the session scopes and login credentials were not being initiated and terminated together (upon login/logout). Before, a user was clicking 'logout' and it was clearing the session scopes without invoking CFLOGOUT. Now, I fixed that, but I have another problem, which is that I can't log into the application on two different browsers or servers at the same time (even if I'm using different login usernames). Any suggestions would be appreciated.
    <cfcomponent displayname="Application" output="false">
        <cfset this.name = 'SampleApp'>
        <cfset this.SessionManagement = true>
        <cfset this.SetClientCookies = true>
        <cfset this.SessionTimeout = CreateTimeSpan( 0, 0, 5, 0 ) />
    <cffunction name="onSessionStart" access="public" returntype="void" output="false">
        <cfset session.hostname = 'http://'&#CGI.HTTP_HOST#&'/'>
        <cfset session.dbase = 'localdb'>
        <cfset session.roles = ArrayNew(1)>
        <cfreturn>
    </cffunction>
    <cffunction name="onApplicationStart" access="public" returntype="boolean" output="false">
        <cflog file="SampleApp" type="information" text="Application started." />
        <cfreturn true>
    </cffunction>
    <cffunction name="onApplicationEnd" returntype="void" output="false" hint="Executes on session timeout or if server shuts down.">
        <cfcookie name="CFID" value="#CFID#" expires="now">
        <cfcookie name="CFTOKEN" value="#CFTOKEN#"  expires="now">
        <cfreturn>
    </cffunction>
    <cffunction name="onRequestStart" access="public" returntype="void" output="true" hint="Executes before each page processes.">
        <cfargument name="targetPage" type="String" required="true"/>
            <cfsilent>
            <cfif GetAuthUser() NEQ ''>
                <cfif NOT isDefined('session.uname')>
                    <cfif CGI.HTTP_REFERER DOES NOT CONTAIN "login.cfm">
                        <cfinclude template="expired.cfm">
                        <cfabort>
                    </cfif>
                </cfif>
            </cfif>
            <cflogin>  
                <!--- Flash Remoting setCredentials() passes cflogin.user and cflogin.password using checklogin.cfc --->
                <cfif IsDefined('cflogin')>        
                    <cfquery name="qValidateLogin" datasource="#session.dbase#" username="#cflogin.name#" password="#cflogin.password#">
                        SELECT    role
                        FROM    session_roles
                    </cfquery>
                    <cfif qValidateLogin.RecordCount GT 0>
                        <cfloginuser name="#cflogin.name#" password="#cflogin.password#" roles="#qValidateLogin.ROLE#">
                        <cflog text="User - #cflogin.name#" type="Information" file="Filename" date="yes" time="yes">
                    <cfelse>
                        <cfinclude template="login.cfm">
                        <cfabort>
                    </cfif>
                <cfelse>
                    <cfif right(arguments.targetPage,10) is "logout.cfm">
                        <cflocation url="index.cfm">
                        <cfabort>
                    <cfelse>              
                        <cfinclude template="login.cfm">
                        <cfabort>  
                    </cfif>          
                </cfif>
            </cflogin>
            </cfsilent>      
    </cffunction>
    </cfcomponent>

    Oh no, that was my mistake. Thank you for catching that! That query is currently not being used on my Application.cfc page, which is why I wasn't having problems with it, but I'm glad you pointed it out to me. I had that code in my Application.cfc file just incase I wanted to check login from somewhere else, but my login query is actually being called with Flash Remoting using setCredentials() to connect to login.cfc. This is the correct query in my login.cfc file:
                <cfquery name="qValidateLogin" username="#session.uname#" password="#session.pword#" datasource="#session.dbase#">
                    select role from session_roles where role like 'xxxxx%'     
                </cfquery>
    I do think I figured out a solution to my problem though. I found out how to use applicationToken, which I understand if it is not set, by default will be the value of application.Name. If you want users to be able to log into multiple instances of  your application at the same time, you would give the applicationToken the same value. This would be great for clustered servers or sites with sub-domains.
    If you wanted to force only one login for the three different sites, you could give this a different value. VERY useful. So I have:
    <cfcomponent displayname="Application" output="false">
        <cfset this.name = 'SampleApp'>
        <cfset this.SessionManagement = true>
        <cfset this.SetClientCookies = true>
        <cfset this.SessionTimeout = CreateTimeSpan( 0, 0, 5, 0 ) />
        <cfset this.loginStorgage = "session">
        <cfset this.applicationtoken = 'SampleAppSub'>
    Now, I can log into this site on my development machine with multiple browsers pointing to the same site hosted on different servers - with no problem. I never had an issue with this before, but something else I recently added into my code in Application.cfc made this not work. I should probably also mention that I work on many different applications that all use the same application.Name even though they are different sites - we do this so the same settings can be deployed on different servers.
    With the applicationToken settings, I have it working again. Perhaps what made it break was setting this.loginStorage = "session"? Before this was not set and was using the default value of  "cookies" which I didn't want - because my site is used by different people on the same box and we have clustered servers.

  • HT1146 I can not get my mail to send on my mac. It has been fine until about 2 hours ago, incoming mails are fine. I have jused all of my 3 accounts and I can't send from any og them (they are all on different servers) anyone have nay ideas on how I can f

    I can not get my mail to send on my mac. It has been fine until about 2 hours ago, incoming mails are fine. I have jused all of my 3 accounts and I can't send from any og them (they are all on different servers) anyone have nay ideas on how I can fix this?

    Jailbreaking violates the Apple warranty and licensing agreement and voids ALL support from Apple.  No one on here can help you as doing so is a violation of the Terms of Use of these Communities.  If you send the iPad to Apple they will just send it back to you as they are not permitted to work on a machine that has been jailbroken.

  • Smartform in different servers.

    Hi gurus,
    My requirement is that i need to print a particular text in the smartform .this text should appear in the developement server and quality server but not in the production server.
    is there is any condition by which we can restrict the display of the text in different servers.The developement server has system id DE1 and quality ME1 and production PE1.
    Is there any way we can use these system ids as these are uni

    Hi
    U can check the system variable SY-SYSID, here u can find the Server ID:
    IF SY-SYSID = 'DE1' OR SY-SYSID = 'ME1'.
    ENDIF.
    Max

  • How do i run two threads with different sleep times?

    How do i run two threads with different sleep times?
    Ive got thread A and thread B, they both update a jpanel.
    They both start when i press the start button.
    However thread A updates every 250ms and thread B updates every 1000ms. i cant just run them both at 250ms becuase this will mess it up.
    So for every four runs of thread A i want thread b to only be run once
    Does anyone know how to do this?
    Thanks, Ant...

    ok, ive done it but now i cant stop it!
    ive added buttons to start and stop, the start button works but the stop button doesnt. why doesnt "t.stop();" work?
        public void run() {
            while(t == Thread.currentThread()) {
                System.out.println("No " + t.getName());
                if (t.getName().equals("1")){
                    try {
                        t.sleep(1000); // in milliseconds
                    } catch (InterruptedException e) {}
                } else{
                    try {
                        t.sleep(250); // in milliseconds
                    } catch (InterruptedException e) {}
        }

  • Test connectivity to different servers on Solaris 10

    friends,
    I have a query for a connectivity test with different servers, explained the case for more details: In a windows environment if I have verified connectivity to another remote computer within the network with the command: ping remotehostname
    on Solaris 10 as I can perform this test?
    Thanks

    the command is:
    ping remotehostname
    Seriously, these kind of questions must be much easier to find answer to by using google or the Solaris documentation, its a quite basic question.
    To give a more serious answer "ping" is in /usr/sbin, so if you don't find ping you dont have /usr/sbin in your $PATH. In which case you can run:
    /usr/sbin/ping remotehostname
    If you get "unknown host remotehostname" you need to fix your DNS resolving by adding "dns" to the line which begins with "hosts" in /etc/nsswitch.conf and create a /etc/resolv.conf..
    .7/M.

  • BPEL and ESB in different Servers

    Hi ,
    What is the advantage of having BPEL PM and ESB installed in different servers ?

    In my knowledge it has it own merits and demerits
    IF (BPEL and ESB) installed in dfferent OC4Js (JVMs)
    Merits
    1) Individual JVM for each component means more memory allocation and support from JVM
    2) More number of processes can be deployed.
    DeMerits
    1) ESB and BPEL communication can happen via SOAP over HTTP only whereas had these been deployed in the same JVM (oc4j) it can do native communication.
    Edited by: cdmnagaraj on Apr 22, 2009 5:17 AM

  • Best way to compare data of 2 tables present on 2 different servers

    Hi,
    We are doing data migration and I wil like to compare data between 2 tables which are present on 2 different server. I know to find the difference i can go for minus or full outer join and by creating the database link.
    But my problem is the volume of the data. The tables under consideration has approximately 40-60 columns and number of rows in each tables are around 60-70 million. Also both the tables are on 2 diffferent servers.
    I would like to know
    1] What will be the best way to compare the data and print the difference from performance perepective? I know that if I am going for DB links then its will definitely impact the performance as the tables are across 2 different servers.
    2] Is it advisable to go for using SQL - PL/SQL for this kind of senario or dump the data in flat files and use C or C++ code to find the difference.
    Regards,
    Amol

    Check this at asktom.oracle.com. Search for "Marco Stefanetti" and follow the few posts between Marco and Tom. As far as your tables being on separate servers, you could consider dumping the data to file and using external table or using CTAS ( create table as select ) to get both tables locally.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2151582681236

  • ESB and BPEL in different servers

    Hi ,
    Is there any performance based advantage when we have BPEL and ESB in different servers ?

    If you seperate them, it will have impacht on the perfromance. Services are called over the network, assuming BPEL and ESB are on different servers. Otherwise they can call each other via native binding if ESB and BPEL are in the server and container.
    Marc
    http://orasoa.blogspot.com

Maybe you are looking for

  • Need help with Holiday script

    Hi All, I am not sure why my Holiday scripts keep returning Null, I have attached the script and xml files. If someone can help would be great. Thanks, Hamed

  • File to multiple files scenario

    Hi there, I will try to explain my scenario. I pick up a file with several lines and I need to create one output file per line - <RECORD> + <LINE_ITEM> + <LINE_ITEM> + <LINE_ITEM> -</RECORD> I set up message mapping and interface mapping target to un

  • Disabling / Turning off  (or on) DHCP for IPV4 and IPV6 from Terminal

    It took some looking to find this info, so I figured I'd post it to save someone else a lot of looking.  networksetup -setv4off Ethernet networksetup -setv6off Ethernet networksetup -setdhcp Ethernet networksetup -setv6automatic Ethernet You can chan

  • Delivery date and loading date is same

    Hello , Issue decription: The system calculating delivery=loading date , though the route is maintained for 9 days trasit days. This problem is with only one routeA. When i have created SO for material M123 with route "B" shipping Point 0001, the sys

  • Radio spectrum measurements with USRP

    Hello everybody, I am using the attached VI for real-time spectrum measurements. However, i need to save the data after averaging is done and restart the averaging in order to save the data for the next time instant. Is there any suggestion on how to