Monday May 19, 2008
Monday May 19, 2008
import java.io.*;
public class ReadString {
public static void main (String[] args) throws Exception {
System.out.print("Enter your name: ");
// open up standard input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine();
System.out.println("Thanks: " + name);
}
}
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JLabel l = new JLabel("label:");
JTextField f = new JTextField(10);
JButton b = new JButton("Calc");
panel.add(l);
panel.add(f);
panel.add(b);
frame.getContentPane().add(panel);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
public class Test2 {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(4,2));
JLabel l1 = new JLabel("label:");
JTextField f1 = new JTextField(10);
panel.add(l1);
panel.add(f1);
JLabel l2 = new JLabel("label:");
JTextField f2 = new JTextField(10);
panel.add(l2);
panel.add(f2);
JLabel l3 = new JLabel("label:");
JTextField f3 = new JTextField(10);
panel.add(l3);
panel.add(f3);
JButton b = new JButton("Calc");
panel.add(b);
frame.getContentPane().add(panel);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
public class Test3 {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(4,1));
JLabel l1 = new JLabel("label:");
JTextField f1 = new JTextField(10);
JPanel panel1 = new JPanel();
panel1.add(l1);
panel1.add(f1);
panel.add(panel1);
JLabel l2 = new JLabel("label:");
JTextField f2 = new JTextField(10);
JPanel panel2 = new JPanel();
panel2.add(l2);
panel2.add(f2);
panel.add(panel2);
JLabel l3 = new JLabel("label:");
JTextField f3 = new JTextField(10);
JPanel panel3 = new JPanel();
panel3.add(l3);
panel3.add(f3);
panel.add(panel3);
JButton b = new JButton("Calc");
JPanel panel4 = new JPanel();
panel4.add(b);
panel.add(panel4);
frame.getContentPane().add(panel);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
Wednesday Jun 20, 2007
Friday Dec 15, 2006
if (!(wait)) break;
wait();
class CRun1 implements Runnable {
String s;
CountDownLatch c = new CountDownLatch(1);
CRun1(String s) {
this.s = s;
}
public void run() {
System.out.println("Lrun " + s);
try {
Thread.sleep(4000);
} catch (InterruptedException ex) {
} finally {
}
System.out.println("count down - notify for run " + s);
c.countDown();
}
public void get() {
while (true) {
try {
c.await();
break;
} catch (InterruptedException ex) {
}
}
System.out.println("recv notify...");
}
}
class Run1 implements Runnable {
String s;
boolean wait = true;
Run1(String s) {
this.s = s;
}
public synchronized void run() {
System.out.println("run " + s);
try {
Thread.sleep(4000);
} catch (InterruptedException ex) {
}
wait = false;
System.out.println("notify for run " + s);
notifyAll();
}
public synchronized void get() {
while (true) {
try {
System.out.println("wait...");
wait();
if (!(wait)) break;
System.out.println("recv notify...");
} catch (InterruptedException ex) {
}
}
}
}
public class TestThread {
public synchronized void testIt() throws Exception {
Run1 run1 = new Run1("1");
Run1 run2 = new Run1("2");
Thread t1 = new Thread(run1);
t1.start();
Thread t2 = new Thread(run2);
t2.start();
run1.get();
run2.get();
}
public static void main(String[] args) throws Exception {
TestThread t = new TestThread();
t.testIt();
}
}
Wednesday Dec 06, 2006
public interface ComputeServer extends Remote {
public double integrate(String function, double min, double max) throws RemoteException;
}
public class ComputeServerImpl extends UnicastRemoteObject implements ComputeServer {
public double integrate(String function, double min, double max) throws RemoteException {
...
}
}
public double integrate(String function, double min, double max) throws RemoteException {
class FunctionToIntegrate {
String function;
int min;
int max;
}
public double integrate(FunctionToIntegrate function);
class FunctionToIntegrate extends Serializable {
...
}
public class ComputeServerImpl extends UnicastRemoteObject implements ComputeServer {
public void integrate(String function, Remote callback) throws RemoteException {
...
}
}
Friday Nov 10, 2006
// Submit jobs to run
for (int i = 0; i < 50; i++) {
System.out.println("Creating Remote Command: " + i);
jt[i] = session.createJobTemplate();
jt[i].setRemoteCommand(exec);
ids[i] = session.runJob(jt[i]);
}
A full example is provided on the Developer Network site by Fay Salwen, one of our Grid experts.
Thursday Nov 09, 2006
> ./cog-4_1_4/bin/grid-cert-request -cn "Pascal Ledru" >scp .globus/usercert_request.pem root@myserver.central.sun.com:usercert_request.ledru.pem
> /usr/local/globus-4.0.3/bin/grid-ca-sign -in usercert_request.ledru.pem -out usercert.ledru.pem
> scp root@myserver.central.sun.com:usercert.ledru.pem .globus/usercert.pem > ./install/cog-4_1_4/bin/grid-proxy-init
"/O=Grid/OU=GlobusTest/OU=simpleCA-myserver/CN=Pascal Ledru" globus
./cog-file-transfer -s file:///home/pl108086/test.txt -d gridftp://myserver.central.sun.com:2811/tmp/TEST.txt
> printenv HZ= SHELL=/bin/bash TERM=xterm LC_ALL=C MAIL=/var/mail/globus PATH=/usr/local/bin:/usr/bin:/usr/sfw/bin:/usr/dist/share/devpro/5.x-i386/bin:/usr/ccs/bin:/usr/dist/exe PWD=/etc/grid-security LANG=C TZ=US/Mountain SHLVL=2 HOME=/users/globus LOGNAME=globus LC_CTYPE=C _=/usr/bin/tcsh HOSTTYPE=i86pc VENDOR=sun OSTYPE=solaris MACHTYPE=i386 USER=globus GROUP=other HOST=myhost GPT_LOCATION=/usr/local/globus-4.0.3 CC=/usr/dist/share/devpro/5.x-i386/bin/cc GLOBUS_LOCATION=/usr/local/globus-4.0.3 GCC=/usr/sfw/bin/gcc
./configure --prefix=$GLOBUS_LOCATION --with-flavor=gcc32dbg
make
/usr/ccs/bin:/usr/dist/exe
file:/tmp/testgt/gt4.0.3-all-source-installer/source-trees/wsrf/java/core/source/build.xml:211: Compile failed; see the compiler error output for details.
import org.apache.axus.enum.Scope;I edited the build file to add the -source 1.4 option such as:
source="1.4"
echo "Your build completed successfully. Please run make install." Your build completed successfully. Please run make install.
> make install /usr/local/globus-4.0.3/sbin/gpt-postinstall running /usr/local/globus-4.0.3/setup/globus/setup-globus-common..[ Changing to /usr/local/globus-4.0.3/setup/globus ] creating globus-sh-tools-vars.sh running /usr/local/globus-4.0.3/setup/globus/setup-globus-job-manager-fork..[ Changing to /usr/local/globus-4.0.3/setup/globus ] find-fork-tools: WARNING: "Cannot locate mpiexec" find-fork-tools: WARNING: "Cannot locate mpirun" checking for mpiexec... no checking for mpirun... no find-fork-tools: creating ./config.status config.status: creating fork.pm ..Done
> $GLOBUS_LOCATION/setup/globus/setup-simple-ca
creating CA config package... /usr/local/globus-4.0.3/setup/globus/setup-simple-ca: GLOBUS_LOCATION=/usr/local/globus-4.0.3: is not an identifier
#! /bin/shto
#! /bin/bash
creating CA config package... ERROR: Unable to configure the simple_ca 9a7cd758 setup packageCorrected GPT_LOCATION such as:
setenv GPT_LOCATION /usr/local/globus-4.0.3Then ran as root:
> $GLOBUS_LOCATION/setup/globus_simple_ca_9a7cd758_setup/setup-gsi -default > $GLOBUS_LOCATION/bin/grid-cert-request -host myhost.central.sun.com
Wednesday Sep 27, 2006
cat cs_master.o68935.2
Sleeping for 0 seconds
Your job-array 68936.4-102:1 ("cs_ephemeralworker -ephemeral") has been submitted
Sep 27, 2006 4:43:43 PM com.sun.computeserver.master.Master run
INFO: Master starting
Sep 27, 2006 4:44:05 PM com.sun.computeserver.integralpi.PiGenerator done
INFO: Master PI:3.1415906524138111994160239945727946065207750695568908515112969308267806110
10577374635946745511251244209674355608893092721700668334960937500
Sep 27, 2006 4:44:05 PM com.sun.computeserver.master.Master doWaitForFeedback
INFO: Master exiting via WAIT
Sep 27, 2006 4:44:05 PM com.sun.computeserver.mm.MasterAspect doOutput
INFO:
Job Succeeded
Sep 27, 2006 4:44:05 PM com.sun.computeserver.mm.MasterAspect doOutput
INFO:
Master Job Start Time : 2006-09-27 16:43:43.674
Master Job End Time : 2006-09-27 16:44:05.187
Total Job Execution Time : 21.513 Seconds
Total Processed Tasks : 100
Total Failed Tasks : 0
Total Submitted Tasks : 100
Generated : 100
Fissioned : 0
Task Throughput : 4.7 Tasks per Second
Average Task Execution Time : 0.215 Seconds per Task
cat cs_ephemeralworker.o68936.86 Sleeping for 8 seconds Sep 27, 2006 4:44:03 PM com.sun.computeserver.worker.WorkerWatcher init INFO: Worker active on nyc1r226cpn06.retail.nyc1.sungrid.net Sep 27, 2006 4:44:09 PM com.sun.computeserver.worker.WorkerWatcher goAway INFO: Worker exiting nyc1r226cpn06.retail.nyc1.sungrid.net
Tuesday Sep 19, 2006
#!/bin/ksh prstat 20 20 > prstat.out & java ExampleLooking for the Java process in this example:
7956 user0103 203M 13M cpu0 0 0 0:00:20 30% java/12 7956 user0103 203M 13M cpu1 0 0 0:00:40 42% java/12 7956 user0103 203M 13M cpu1 0 0 0:01:00 47% java/12 7956 user0103 203M 13M cpu1 0 0 0:01:19 49% java/12 7956 user0103 203M 13M cpu1 0 0 0:01:40 49% java/12
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
27796 root 13M 10M sleep 49 0 1:24:39 0.2% dsmonitor/1
9 root 9080K 8140K sleep 59 0 0:00:46 0.1% svc.configd/14
304 root 5056K 2628K sleep 59 0 0:04:17 0.0% automountd/3
7955 user0103 4408K 3992K cpu1 34 0 0:00:00 0.0% prstat/1
754 root 31M 28M sleep 59 -10 0:27:05 0.0% sge_execd/1
7950 root 4156K 1468K sleep 54 -10 0:00:00 0.0% sge_shepherd/1
7954 user0103 1152K 912K sleep 14 0 0:00:00 0.0% 66414/1
7 root 9124K 8140K sleep 59 0 0:03:03 0.0% svc.startd/14
7956 user0103 7716K 1280K cpu0 24 0 0:00:00 0.0% java/1
323 nobody 2932K 1836K sleep 59 0 0:07:32 0.0% gmond/1
143 root 4340K 3456K sleep 59 0 0:04:54 0.0% nscd/26
27785 root 3832K 1972K sleep 59 0 0:00:10 0.0% syslogd/15
282 root 1952K 1160K sleep 100 - 0:02:49 0.0% xntpd/1
150 root 2256K 1476K sleep 59 0 0:00:00 0.0% devfsadm/6
122 root 2120K 1300K sleep 59 0 0:00:00 0.0% syseventd/14
Total: 40 processes, 156 lwps, load averages: 0.01, 0.00, 0.00
Monday Sep 18, 2006
1 node: Average: 3.1411545250056307 with 1 nodes. 2 nodes: Average: 3.141313165330142 with 2 nodes. 20 nodes: Average: 3.1416765781116878 with 20 nodes. 200 nodes: Average: 3.141568127864779 with 200 nodes.Actually 3.1415 is a fairly good approximation: π to one MILLION decimal places
#!/bin/ksh
#$ -N Buffon
#$ -cwd
# Set the environment variables
if [ -f $HOME/.profile ]; then
. $HOME/.profile
fi
numClients=$1
echo "Starting the server..."
echo "Number of clients: "$numClients
svrResp=$(qsub -N server startServers.ksh)
echo svrResp is $svrResp
svrJobId=$(echo "$svrResp" | awk '{print $3}')
echo svrJobId is $svrJobId
# Wait until the server is started
status="not running"
until [ "$status" == "r" ]
do
status=$( qstat | nawk '/'$svrJobId'/ {print $5}' )
echo Server job status is $status
sleep 10
done
#Wait until the serverhost file is created
filename="$HOME/serverhost"
until test -f $filename
do
sleep 10
done
# then pull the server node name from the file
servernode=$(cat $filename)
rm $filename
echo "Server is running on" $servernode "Submitting a set of clients to the grid for remote execution..."
qsub -N clients -t 1-$numClients startClient.ksh $servernode
echo "Submitting a cleanup job that will wait until the clients are complete"
qsub -hold_jid clients cleanup.ksh $svrJobId