Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Cheenath Ajay

Ranch Hand
+ Follow
since Jan 26, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cheenath Ajay

Hi Greg Charles,

I 100% agree with you on this, XML conversion during serialization and de-serialization is time consuming process.
I was under a process of evaluating available techniques to serialize and de-serialize huge data in the best manner.

A XML framework may a decent representation of data, but may not be the best performer during data transfer.

Now I can leave the users of my framework to externalize object that needs to transferred to remote machine in an optimized manner (as they know the object better), or create a generic wrapper code which can serialize any object to minimize the object size in a faster manner.

There are couple of ideas in my mind.
1. Use NIO for data transfer
2. Transfer the object in compressed format
3. Evaluate Google Protocol Buffer

Do you have any suggestion?

Thanks in advance,
-Ajay






9 years ago
In my application I am using Java default Object serialization to transfer object from one JVM to the other. The object transfer is through tcp socket.

As the object size is really huge (there are multiple data-structures like ArrayList, HashMap and so on ), the object serialization, object transfer through tcp socket and de-serialization taking relatively huge time.

To solve this issue I tried using Xstream (XML based serialization, which is supposed to be better performer than Java serialization). Unfortunately since the object is huge in size the XML generation, size of XML, de-serialization taking more time than Java serialization.

Can anyone suggest me a better serialization methodology in this scenario?
9 years ago

I am all set.
Thanks a million for you support
9 years ago
Thanks Rob.

Strange but found one interesting thing.
Whenever you call classObjStream.read() method, that call reads one byte from the stream, hence whenever you try reading from stream using read(byte[]) next time, it will always give you bytes from the stream after the first byte.(one byte missing).

FileInputStream classObjStream = new FileInputStream(new File(fileName));
byte[] classBytes = new byte[1024];
int length = classObjStream.read(); //Here is the issue.........

System.out.println("length - "+length);
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
int count;
while((count = classObjStream.read(classBytes)) > -1){ // assign, then compare to -1
System.out.println(count);
byteArray.write(classBytes, 0, count); // only write as many bytes as were read
}
System.out.println(new String(byteArray.toByteArray()));
return byteArray.toByteArray();
9 years ago
Got the ans:
Wasted a day going behind this issue

Used below code to read bytes from a class then problem solved..

byte[] bytes = new byte[(int)length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
}

A bit crazy, I was expecting below code will do the same !!!

ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
while(classObjStream.read(by) > -1){
byteArray.write(by);
}

Any way things started working now!!


9 years ago
Thanks.

I tried changing it, but still getting the same error.
FileInputStream classObjStream = new FileInputStream(new File("D:\\softwares\\parallel\\task-test\\bin\\com\\tm\\grid\\Test.class"));
int length = classObjStream.read();
byte[] by = new byte[length];
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
while(classObjStream.read(by) > -1){
byteArray.write(by);
}
Class class1 = defineClass("com.tm.grid.Test",byteArray.toByteArray(), 0, byteArray.toByteArray().length);
System.out.println(">>>>>>>>>>>>"+class1);
return class1;

Any clue??

9 years ago
Hi I am trying to read a local class file and load the class object into my custom class loader

Code;
public Class classLoad() throws IOException {
FileInputStream classObjStream = new FileInputStream(new File("D:\\softwares\\parallel\\task-manager\\bin\\com\\tm\\grid\\TaskManager.class"));
int length = classObjStream.read();
byte[] by = new byte[length];
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
while(classObjStream.read(by) > 0){
byteArray.write(by);
}
Class class1 = defineClass("com.tm.grid.TaskManager",byteArray.toByteArray(), 0, byteArray.toByteArray().length);
System.out.println(">>>>>>>>>>>>"+class1);
return class1;
}
But unfortunately I am getting below error once I tried to execute this
-----------------------
Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 4273651200 in class file com/tm/grid/TaskManager
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)

Can anyone help me on this?

Thanks in advance,



9 years ago
Thanks a lot Henry for the details.
Let me give a try.

Regards,
9 years ago
To improve my system performance I am planning to use distributed computing (using java).
I found several interesting distributed/grid java based frameworks to share CPU.
Can anyone suggest me a good framework to share memory?

Thanks and Regards,
9 years ago
How array memory allocation is managed in Java?
In the sense, I have a Object two dimensional array initialized with say obeject[10][10].

How much will be memory allocated for this initialization.

The reason is in the array initialized, my program is going to insert Object instance into some of the array indexes. That means some of the array indexes will be null/empty. How expensive are those empty/null arrays?

Thanks in advance,
-Ajay
10 years ago

Hi All,

I am facing a strange problem in my solaris server.
Once after the reboot of my Solaris Server rmiregistry is started as below (init.d process)
su - xyz -c "/export/home/jres_solaris/jre1_5_0/bin/rmiregistry &"

Some how after some time(approx 10 mins) rmiregistry went down.

Can some any one help me if there is any existing rmiregistry issues or if I am doing something wrong??

Thanks in advance
-Cheenath
11 years ago
Hi All,

In my Solaris(4 CPU) box there are multiple JVMs are running to serve different components of the application. Due to several design holes most of these components are consuming max CPU. Now I am planning to reduce the priority of thread execution in one of the least used component to release CPU for those other JVMs/Components to process faster. Since they are running in different JVMs how setting priority of task A in JVM � X will help task � B in JVM � Y will help? If that wont help what will be the best way to solve this issue??

Thanks in advance,
-Ajay
But this is happening only one PC.
Yes there are some settings in that PC or browser which stops applet to process any more.

I will check whether a screen saver doing this.

Thanks,

-Cheenath
12 years ago
I have an application which will plot chart(jfree chart) by fetching data from server.

Particularly in one Windows machine if I keep system idle for more than 20-60 min Applet will stop calling the server for data and stop plotting chart.

Can any one help me in figuring out the root cause of this issue?
I suspect it is some System settings which bring the JVM to idle, if so any one guide me to figure out that?

Thanks in advance,

-Cheenath
12 years ago
I have an RMI interface which compiled using Java 1.5(Which has <template> def in it)

How can we use this RMI in Java 1.4

Thanks in advance

-Ajay Cheenath
12 years ago