Performance of java nio with dd in linux.

Hi
I ran this code in java to dump 0s in a file of size 1gb and tried the same with dd in linux.
Java code : I use a preinitialized array (the data) and fill a mappedbytebuffer with it.
package filePersistence.test;
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class TimeLineTest {
     private static final int BYTE_LENGTH = 1000;
     //this is the input
     static byte[] b = new byte[BYTE_LENGTH];
     public static void main(String[] arg) throws Exception
          //initializing the input
          for (int i=0;i<BYTE_LENGTH;i++)
               b[i] = 0;
          File file = new File(arg[0]);
          RandomAccessFile raFile = new RandomAccessFile(file,"rw");
          FileChannel fChannel = raFile.getChannel();
          int loopCount = 1000000;
          MappedByteBuffer mbuffer = fChannel.map( FileChannel.MapMode.READ_WRITE ,0,loopCount * BYTE_LENGTH);
          //System.out.println(" going to fill in a file" + file.getName());
          long k = 0;
          long startTime = System.currentTimeMillis();
          for (int i=0;i<loopCount;i++)
     //populate the mapped buffer
               mbuffer.put(b);
          //persist into the file
          mbuffer.force();
          long endTime = System.currentTimeMillis();
          System.out.println(" file filled size1 "+file.length());
          System.out.println(" time " + (endTime - startTime));
On a linux machine this takes around 7 secs while dd used as
"dd if=/dev/zero of=mytestfile.out bs=1000 count=1000000"
1000000+0 records in
1000000+0 records out
1000000000 bytes (1.0 GB) copied, 4.618 seconds, 217 MB/s
4.6 and 7 differ quite a lot. Is there a way the java code can be improved to match dd ?(-sever does not help)
Thanks
Sumanta

Hi
Can this be called a dd equivalent code ?
package filePersistence.test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class TimeLineTest {
     private static final int BYTE_LENGTH = 1000;
     //this is the input
     static byte[] b = new byte[BYTE_LENGTH];
     public static void main(String[] arg) throws Exception
          //initializing the input
          for (int i=0;i<BYTE_LENGTH;i++)
               b[i] = 0;
          String srcFile = arg[0] + "_src";
          FileOutputStream fos = new FileOutputStream(srcFile);
          fos.write(b);
          fos.getFD().sync();
          fos.flush();
          fos.close();
          RandomAccessFile srcraFile = new RandomAccessFile(srcFile,"rw");
          FileChannel srcChannel = srcraFile.getChannel();
          File file = new File(arg[0]);
          RandomAccessFile raFile = new RandomAccessFile(file,"rw");
          FileChannel raChannel = raFile.getChannel();
          int loopCount = 1000000;
          //MappedByteBuffer mbuffer = fChannel.map( FileChannel.MapMode.READ_WRITE ,0,loopCount * BYTE_LENGTH);
          //System.out.println(" going to fill in a file" + file.getName());
          long startTime = System.currentTimeMillis();
          for (int i=0,position=0;i<loopCount;i++,position+=BYTE_LENGTH)
     //populate the mapped buffer
               //mbuffer.put(b);
               raChannel.position(position);
               srcChannel.transferTo(0, BYTE_LENGTH, raChannel);
          //persist into the file
          //mbuffer.force();
          raFile.getFD().sync();
          raChannel.close();
          raFile.close();
          long endTime = System.currentTimeMillis();
          System.out.println(" file filled size1 "+file.length());
          System.out.println(" time " + (endTime - startTime));
}

Similar Messages

  • Java connectivity with db2 in linux

    hi all,
    i wish to know how to connect java with db2 in linux.actually which is the string that is to be included in the following:
    class.forName("//which is the string that is to be included here");
    Connection con("jdbc:????");

    hi all,
    i wish to know how to connect java with db2same as every other database and OS. JDBC is the way.
    in linux.actually which is the string that is to be
    included in the following:
    lass.forName("//which is the string that is to be
    included here");full name of the DB2 JDBD driver class.
    Connection con("jdbc:????");look at the docs for your JDBC driver to figure out what the URL needs to be.
    %

  • Java appl. with oracle on Linux

    Hello all,
    I would like to ask how to connect my Java application to
    Oracle on Linux. Is there any JDBC driver ?
    null

    Hi Mark,
    I am also running Oracle 8.0.5 in my RD6.0 machine.
    I installed Developer2000 into my win98 machine.
    I tried to login using the developer2000 into the
    oracle running under linux but connection cannot
    go through. I don't know the reason to this. Though
    I can use the SQL*Plus to connect to this database
    from win98, can you figure out what is wrong with
    my setup?
    Thanks,
    -Paul
    Mark Kirkwood (guest) wrote:
    : Hi all,
    : I thought you guys might be interested to know that this stuff
    : is used out there...
    : I work for a Government property management company ( Housing
    : New Zealand ), and they were looking at downsizing their
    systems
    : infrastructure. A subset of the business was picked to pilot a
    : downsized system.
    : We ported from :
    : "thin client" : Citrix Winframe, Developer 2000, HPUX , Oracle
    : 7.3
    : to a :
    : client server : Win95, Developer 2000, RedHat 6.0, Oracle
    8.0.5SE
    : Instead of running 80 users on :
    : 80 P300 PCs, Winframe Client +
    : 1 4xP200 Winframe/NT, Developer 2000 +
    : 1 HP-PA/Risc, HPUX ,Oracle 7.3.3
    : We are running 5 users on :
    : 5 P300 PC Win95, Developer 2000 +
    : 1 P300 PC RedHat 6.0, Oracle 8.0.5, samba
    : ( Obviously this was the pilot subset ! )
    : Although this represents a "step backwards" in deployment
    : architecture ( 3 tier - 2 tier ), it represented a decrease in
    : cost infrastructure per user ( No Winframe/NT License, No
    : expensive Proprietry hardware, only 1 ( Cheap ) propritary o/s
    : Win95 ).
    : We went live with this beast on 1 Aug.
    : The Redhat box has been rebooted once since them - not by us (
    : Power outage at the site ).
    : The server is just idling with 5 concurrent connections.
    : Oracle 8.0.5/Redhat is rock solid as far as we can tell !
    : ( with the right patches ....
    : for those interested they are
    : 8.0.5.1 patchset
    : redo log async write - bug 882446
    : glibc patch
    : setuid security patch
    : Cheers
    : Mark
    null

  • Java NIO with ByteBuffer

    Hi guys,
    I search the forum and the web too, there are many pros and cons in relation to NIO, and on my free time I was trying to research about it, but there
    are time when some things don't make any sense at all.
    Without NIO:
        FileInputStream foin = new FileInputStream("/home/metitus/Desktop/test");
        FileOutputStream fout = new FileOutputStream("/home/metitus/Desktop/test1");
        int character = 0;
        while((character = foin.read()) != -1)
            fout.write(character);
        }with NIO:
    FileInputStream foin = new FileInputStream("/home/metitus/Desktop/test");
        FileOutputStream fout = new FileOutputStream("/home/metitus/Desktop/test1");
        FileChannel fci = foin.getChannel();
        FileChannel fco = fout.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(1);
        while(fci.read(buffer) != -1)
            buffer.flip();
            fout.write(buffer.array());
            buffer.clear();
        }So guys where is the gain here? Why do I need a ByteBuffer always; it might be useful in some cases but definitely not in all.
    MeTitus

    Well there should be more than one position. You're doing it the slowest way possible. There should be 8192, or 16384, or some large number. And when you raise the size you have to use compact(): buffer.clear() is valid if and only if the buffer size is 1; buffer.compact() is valid for all buffer sizes.
    In fact the loop should look like this to take care of the last write:
    while ((count = in.read(buffer)) >= 0 || buffer.position() > 0)
      buffer.flip();
      out.write(buffer);
      buffer.compact();
    }

  • Slow performance of Java program with Oracle db on Solaris

    Hi all,
    I'm developing a Java program to read a large no. of records (arnd 40,000) from a file and populate into an Oracle database on a Solaris system. I'm using a thin JDBC driver. The problem is that the program runs very slow on Solaris.
    When I run the Java program on a Windows machine (and connect to the Solaris machine) the program runs quickly. However when I run the program on the Solaris machine itself, it runs around 20 times slower. I need the program to run faster in the Solaris environment. Can anyone help?
    The SPARC system used is SunOS 5.8, 4GB memory, 2*750MHz processors
    Thanks a lot
    ers

    The set of RDBMS DVD's can be downloaded from SAP Marketplace. Oracle 9.2 Installation zip file which contains Disk1 Disk2 and Disk3.
    Which Version of Solaris are you running?
    Is it 64 or 32 Bit?
    Regards,
    Damien

  • Converting from CP1252 (Windows) to ISO 8859-1 doesn't work with java.nio?

    Hi
    I'm trying to write some code that checks whether an InputStream contains only characters with a given encoding. I'm using java.nio for that. For tests, I downloaded some character set examples from http://www.columbia.edu/kermit/csettables.html
    When creating the CharsetDecoder, I want to get all errors:
        Charset charset = Charset.forName( encoding );
        CharsetDecoder decoder = charset.newDecoder();
        decoder.onMalformedInput( CodingErrorAction.REPORT );
        decoder.onUnmappableCharacter( CodingErrorAction.REPORT );I then read an InputStream and try to convert it. If that fails, it can't contain the desired encoding:
        boolean isWellEncoded = true;
        ByteBuffer inBuffer = ByteBuffer.allocate( 1024 );
        ReadableByteChannel channel = Channels.newChannel( inputStream );
        while ( channel.read( inBuffer ) != -1 )
          CharBuffer decoded = null;
          try
            inBuffer.flip();
            decoded = decoder.decode( inBuffer );
          catch ( MalformedInputException ex )
            isWellEncoded = false;
          catch ( UnmappableCharacterException ex )
            isWellEncoded = false;
          catch ( CharacterCodingException ex )
            isWellEncoded = false;
          if ( decoded != null )
            LOG.debug( decoded.toString() );
          if ( !isWellEncoded )
            break;
          inBuffer.compact();
        channel.close();
        return isWellEncoded;Now I want to check whether a file containing Windows 1252 characters is ISO-8859-1. From my point of view, the code above should fail when it gets to the Euro symbol (decimal 128), since that's not defined in ISO-8859-1.
    But all I get is a ? character instead:
    (})  125  07/13  175  7D                 RIGHT CURLY BRACKET, RIGHT BRACE
    (~)  126  07/14  176  7E                 TILDE
    [?]  128  08/00  200  80  EURO SYMBOL
    [?]  130  08/02  202  82  LOW 9 SINGLE QUOTEI also tried to replace the faulty character, using
        decoder.onUnmappableCharacter( CodingErrorAction.REPLACE );
        decoder.replaceWith("!");but I still get the question marks.
    I'm probably doing something fundamentally wrong, but I dont get it :-)
    Any help is greatly appreciated!
    Eric

    As a suggestion....create a complete example demonstrating the problem. It shouldn't have channel in it since that wouldn't appear to be the problem (decoding is.) You should create the byte array in the example code - populate it with the byte sequence that you think should work. And your code should then demonstrate that it doesn't. Then post that.

  • Troubles with timeout using java.nio.channels and non-blocking sockets

    Hello.
    I have a server application that employs java.nio.channels with non-blocking sockets.
    The server waits for connections. The client should connect and be first in sending data.
    Timeouts are significant! If client exceeds the allowed time to send data, the server should break the connection.
    The huge trouble I've discovered that I cannot control the timeout when client connects but remains silent.
    My code looks as follows:
    <pre>
    Selector oSel;
    SocketChannel oSockChan;
    Socket oSock;
    SelectionKey oSelKey;
    Iterator<SelectionKey> oItSelKeys;
    int iCurrState, iMask, iCount;
    iCurrState = INT_SERVER_WORKING;
    iMask = SelectionKey.OP_ACCEPT | SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE;
    while ( iCurrState == INT_SERVER_WORKING )
    try
    *// retrieving next action*
    iCount = oSel.select();
    if ( iCount > 0 )
    oItSelKeys = oSel.selectedKeys().iterator();
    while ( oItSelKeys.hasNext() )
    oSelKey = oItSelKeys.next();
    oItSelKeys.remove();
    if ( oSelKey.isValid() )
    switch ( oSelKey.readyOps() & iMask ) {
    case SelectionKey.OP_ACCEPT :
    oSockChan = oSSockChan.accept();
    oSockChan.configureBlocking(false);
    oSock = oSockChan.socket();
    oSock.setKeepAlive(true);
    oSockChan.register(oSel,SelectionKey.OP_READ,new MyPacket(oSock.getInetAddress(),oSock.getPort()));
    break;
    case SelectionKey.OP_READ :
    oSelKey.interestOps(0);
    ((MyPacket) oSelKey.attachment()).inRequest(); *// preparing request*
    this.getReader().add(oSelKey); *// sending key to reading thread*
    break;
    case SelectionKey.OP_WRITE :
    oSelKey.interestOps(0);
    ((MyRequest) oSelKey.attachment()).inResponse(); *// preparing response*
    this.getWriter().add(oSelKey); *// sending key to writing thread*
    break;
    case SelectionKey.OP_CONNECT :
    default :
    *// nothing to do*
    catch ( IOException oExcept )
    *// do some actions*
    </pre>
    Timeouts are easily controlled by reading and writing threads (see OP_READ and OP_WRITE ).
    But when a client just connects without consequent data send, the state of this connection remains as OP_ACCEPT. The connection remains open for arbitrarily large time and I cannot control it!
    Please help with idea how can I terminate such connections!

    How can I process the keys that weren't selected at the bottom of the loop? Should I use the method keys() ?Yes. Form a new set from keys() and removeAll(selectedKeys()). Do that before you process selectedKeys().
    And the second moment: as I understood a single key may contain several operations simultaneously? Thus I should use several if's (but not if/else 'cause it's the equivalent of switch ... case ).If there is anything unclear about 'your switch statement is invalid. You need an if/else chain' I fail to see what it is. Try reading it again. And if several ifs were really the equivalent of "switch ... case", there wouldn't be a problem in the first place. They're not, and there is.

  • Need help with java.nio.socket program.

    Can someone please help me here? I am trying to create a class that listens on a socket for an incoming connection, but I am getting the following error on compile:
    SocketIn.java:48: incompatible types
    found : java.nio.channels.SocketChannel
    required: java.net.Socket
    Socket requestSocket = requestChannel.accept();
    Here is my code:
    package NETC;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import java.nio.*;
    import java.nio.charset.*;
    import java.nio.channels.*;
    import java.nio.channels.spi.*;
    public class SocketIn{
         // Buffer for any incoming data.
         private static ByteBuffer inBuffer = ByteBuffer.allocateDirect(1024);
         CharBuffer charBuffer = null;
         public SocketIn(int intPort)throws Exception{
              // Create a non-blocking server socket.
              ServerSocketChannel serverChannel = ServerSocketChannel.open();
              serverChannel.configureBlocking(false);
              // Use the host and port to bind the server socket.
              InetAddress inetAddress = InetAddress.getLocalHost();
              InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, intPort);
              serverChannel.socket().bind(socketAddress);
              // The selector for incoming requests.
              Selector requestSelector = SelectorProvider.provider().openSelector();
              // Put the server socket on the selectors 'ready list'.
              serverChannel.register(requestSelector, SelectionKey.OP_ACCEPT);
              while(requestSelector.select() > 0){
                   System.out.println("Connection Accepted...");
                   // A request has been made and is ready for IO.
                   Set requestKeys = requestSelector.selectedKeys();
                   Iterator iterator = requestKeys.iterator();
                   while(iterator.hasNext()){
                        SelectionKey requestKey = (SelectionKey)iterator.next();
                        // Get the socket that's ready for IO.
                        ServerSocketChannel requestChannel = (ServerSocketChannel)requestKey.channel();
                        // This shouldn't block.
                        Socket requestSocket = requestChannel.accept();
                        inBuffer.clear();
                        requestSocket.read(inBuffer);                    
                        inBuffer.flip();
                        Charset charset = Charset.forName("ISO-8859-1");
                        CharsetDecoder decoder = charset.newDecoder();
                        charBuffer = decoder.decode(inBuffer);
                        iterator.remove();                    
    }

    Well its been about a month and a half so I guess you have your answer. In case you don't...
    // This shouldn't block.
    Socket requestSocket = requestChannel.accept();
    The problem is quite simple. The ServerSocketChannel.accept() returns a SocketChannel. (Channel -> Channel).
    You can get access to the socket using the SocketChannel.
    SocketChannel requestSocketChannel = requestChannel.accept();
    Socket requestSocket = requestSocketChannel.socket();
    But you don't need the socket to read and write.

  • Java NIO locking and NTFS network resources

    Hi all - just ran into a really nasty situation and I was wondering if anyone else has hit it and might have some suggestions.
    Platform: JRE 1.4_02 on a Win XP machine
    The following test code locks a file, then copies it to another location using NIO.
    When I run it with source path on my local drives (C), it works fine. If I run it with source path on a network shared resource, it fails with an IOException with description 'Error performing inpage operation'.
    If I disable the lock immediately before the copy operation, it works fine.
    My conclusion is that there is something about the NIO locking implementation that prevents it from working properly with NTFS volumes on other hosts. Can this be right? I've found the following bug report:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774175
    but this seems like a huge problem that would prevent folks from using NIO in many, many applications. Maybe I'm wrong on something here...
    Anyway, here's the test code:
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    import java.nio.channels.FileLock;
    * Created on May 28, 2004
    * (c) 2004 Trumpet, Inc.
    * @author kevin
    public class test {
         private void createFile(File f) throws IOException{
              FileOutputStream os = new FileOutputStream(f);
              for(int i = 0; i < 10; i++){
                   os.write(i);
              os.close();
         public test() {
              boolean testWithReleasingLockPriorToCopy = false;
              final File f1= new File("w:/temp/test2.lok");
              final File f2 = new File("w:/temp/test.lok");
              f1.delete();
              f2.delete();
              try {
                   createFile(f1);
                   RandomAccessFile raf1 = new RandomAccessFile(f1, "rw");
                   RandomAccessFile raf2 = new RandomAccessFile(f1, "rw");
                   FileChannel ch1 = raf1.getChannel();
                   FileChannel ch2 = raf2.getChannel();
                   FileLock flock1 = ch1.lock();
                  if (!f2.getParentFile().exists() && !f2.getParentFile().mkdirs())
                       throw new IOException("Unable to create directories for destination file '" + f2 + "'");
                  if (testWithReleasingLockPriorToCopy)
                       flock1.release();
                   ch1.transferTo(0, raf1.length(), ch2);
                   raf1.close();
                   raf2.close();
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args) {
              test t = new test();
    }Does anyone have any pointers here? I need to be able to exclusively lock a file on a network drive (preventing any other applications from opening it), then make a copy of it. I can't use regular stream operations, because the lock prevents them from working properly (it appears that, once you grab a file lock using NIO, the only way your application can use the file is via the NIO operations - using stream operations fails...).
    Thanks in advance for any help!
    - Kevin

    i've run into the same problem recently, channels working fine for local file locking, but when you turn to the network, they fail to accurately handle locks.
    i ended up writing a jni utility to ship with my java application that locks files using native windows calls.
    my .c file ends up looking something like this:
    JNIEXPORT jint JNICALL Java_Mapper_NativeUtils_LockFile
    (JNIEnv *env, jobject obj, jstring filename)
    const char* ntvFilename = (*env)->GetStringUTFChars(env, filename, 0);
    int retVal = (int)CreateFile
    ntvFilename
    , GENERIC_WRITE
    , FILE_SHARE_READ
    , 0
    , OPEN_EXISTING
    , FILE_FLAG_SEQUENTIAL_SCAN
    , 0
    //add code to throw java exceptions based on retVal
    if (retVal == (int)INVALID_HANDLE_VALUE)
    return retVal;
    (*env)->ReleaseStringUTFChars(env, filename, ntvFilename);
    return retVal;
    JNIEXPORT jboolean JNICALL Java_Mapper_NativeUtils_UnlockFile
    (JNIEnv *env, jobject obj, jint handle)
         CloseHandle((void *)handle);
    return 1;
    it's a little shy on the error checking side, but it provides support for network file locking that java seems to lack.

  • Java NIO, ByteBuffers and Linksys router

    I have a client server app/game that uses NIO for communication sending ByteBuffers. On a LAN with 5-8 users it runs great. On the internet, through a Linksys router, with one user, it has a blip. I get all my data transmissions except for one buffer. Whenever I chat the buffer contains a size, an int typeID and the encoded string for chat. This particular buffer never makes it to the client on the outside of the router. I have a port forwarded and regular tcp/ip java io sockets stuff works fine. As does al lof the other NIO buffer traffic for locational data, login in and out, etc... ANy thoughts??

    But not sure what would be the performance of those clients?? when compared to Java NIO performance....Telnet isn't a high-performance protocol anyway. Don't worry about it. Use existing code. Get it working. Measure. If you have a performance issue, then worry, while at least you have something you can deploy. It won't be a problem. The router is there to route, not to talk high-speed telnet.

  • Java.nio.BufferOverflowException on big Strings ( 87MB)

    Hi!
    When calling getBytes() on a big String the following exception is thrown:
    java.nio.BufferOverflowException
         at java.nio.charset.CoderResult.throwException(Unknown Source)
         at java.lang.StringCoding$CharsetSD.decode(Unknown Source)
         at java.lang.StringCoding.decode(Unknown Source)
         at java.lang.StringCoding.decode(Unknown Source)
         at java.lang.String.<init>(Unknown Source)
         at java.lang.String.<init>(Unknown Source)
         at com.db.janus.Janus.main(Janus.java:99)
    This happens as soon as the size of the String gets bigger than 92003848 bytes.
    I can reproduce it with the following code:
    String x = new String(new byte[92003848]); // --> OK
    String x = new String(new byte[92003849]); // --> Exception
    JDK Version: 1.4.2_06
    OS: Windows XP
    Is this a known bug / limitation? I found a similar bug related to Java on Linux / Solaris, but this one was about getBytes() with Strings > 16MB.
    Thanks for your help!

    Is there any alternative to solve this problem.I am getting the error
    java.nio.BufferOverflowException .This happens in my mail server when the file six\ze of xml where i have stored data about spam/nonspam grows upto 22mb.I have stored this xml in database as blob.at server startup uploading in in my class.Keeps througout in JVM after every 50 th request saving information back to database(about spam/nonspam).Now if xml size grows i am storing this in string to parse etc.it gives this bug error.Sholud i cahnge my datatype or use something as XML Parser to split my xml in pieces(mechanism i am not aware of at all) so that string just takes some size of xml (but here can i use string builder etc.). Now is there any proper solution to this kind of problem whenever i removes some daya from xml spam mail goes to inbox and vice versa.
    Please suggest me some solution if possible.
    complete error is:
    Servlet initialization failed:
    java.nio.BufferOverflowException
    at java.nio.charset.CoderResult.throwException(CoderResult.java:259)
    at java.lang.StringCoding$CharsetSD.decode([BII)[C(Unknown Source)
             at java.lang.StringCoding.decode(Ljava.lang.String;[BII)[C(Unknown Source)
             at java.lang.String.<init>([BIILjava.lang.String;)V(Unknown Source)
             at java.lang.String.<init>([BLjava.lang.String;)V(Unknown Source)
             at zerocode.core.ByteBlock.toString(ByteBlock.java:89)
             at zcCollab.mailProcessing.NaiveBayesClassifier._getInstanceData(NaiveBayesClassifier.java:275)
             at zcCollab.mailProcessing.NaiveBayesClassifier.initialize(NaiveBayesClassifier.java:86)
             at zcCollab.mailProcessing.SimpleDeliveryManager._setupClassifiers(SimpleDeliveryManager.java:409)
             at zcCollab.mailProcessing.SimpleDeliveryManager.<init>(SimpleDeliveryManager.java:62)
             at zcCollab.zcApp.InfoManagerApp._createDeliveryProcessor(InfoManagerApp.java:307)
             at zcCollab.zcApp.InfoManagerApp.initialize(InfoManagerApp.java:294)
             at zerocode.udm.Application._createInstance(Application.java:168)
             at zerocode.udm.Application.createInstanceForServlet(Application.java:111)
             at zerocode.servlet.UdmServlet._createApplication(UdmServlet.java:67)
             at zerocode.servlet.UdmServlet._initialize(UdmServlet.java:52)
             at zerocode.servlet.GenericServlet.init(GenericServlet.java:116)
             at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:292)
             at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:329)
             at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:657)
             at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
             at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
             at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
             at org.mortbay.http.HttpServer.service(HttpServer.java:879)
             at org.mortbay.http.handler.ForwardHandler.handle(ForwardHandler.java:130)
             at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
             at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
             at org.mortbay.http.HttpServer.service(HttpServer.java:879)
    Thanks
    Vijendra                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help "ascending" to Java NIO

    Hello there.
    I've been using Java for quite some time, but the few really networked client/server applications I have used, have used java.io and java.net. Now, even I have heard the rumours about Java NIO, and I am curious. I have tried reading up and down the API on java.nio.* , but I must say I am still kind of confused.
    Basically, I am looking for some example code, or a thorough explanation of how all the classes and components come together to form efficient asynchronous non-blocking I/O.
    What I picture is a server over TCP/IP meant to handle 100+ clients, written with an emphasis on performance. Think MMORPG, I guess (no no, I am not ambitious enough to want to write one, but I can imagine that gives a good analogy of how I would have the communication set up). The server needs to quickly figure out which clients need to be handled at any given time, with as little overhead or reduntant iteration as possible.
    Ok, I am asking alot perhaps.. I just wonder if anyone could offer links to example source-code, write something to show me, or basically just try to explain to me how this all works.
    I would be very very grateful if anyone stepped up to the plate.
    Thanks,
    -Terje

    Take a look at my thread Taming the NIO Circus. It starts with simple examples of a single thread echo server and a swing client.

  • Analysing SAP Java Memory Usage in Unix/Linux

    Hi,
    I need to analyze the SAP Java memory usage of Unix /Linux machine..NW 7.0
    Please guide with the commands and steps..complete prcedure.
    Based on it I should decide whether to create a new server node (or) increasing heap size
    Thanks in advance

    Hi,
    Do you have performance problems?
    How many CPU's are in the server?
    Did you check Log Configuration for delays or errors?
    Did you tune any exisiting parameters?
    You can add the nodes only if there is performance problems. You may think of adding one node to start with
    Proper number of server nodes within an instance:
    u2013 #ServerNodes = availableMemory / (JavaHeapPermSpaceStack)
    You can calculate the server nodes based on below formula
    No. of server Node = (RAM you want to assign or available RAM in GB)/2.5 ============> for 64-bit system
    No. of server Node = (RAM you want to assign or available RAM in GB)/1.5 ============> for 32-bit system
    Hence as per above discussion, we should go with 5 server nodes means,
    5 = RAM/2.5 (Assuming you are on 64-bit platform)
    i.e. RAM = 12.5 GB
    2). u2013 Configure JVM heap according to Note 723909 and Note 1008311 - Recommended Settings for NW 7.0 >= SR2 for the AIX JVM (J9)

  • Java NIO - copy-on-write buffer

    This is regarding peculiar behavior of a Java program on Linux-IA64 platform.
    I have a Java program that uses MappedByteBuffer. For the same file, there are three buffers - read only, read/write and copy-on-write (cow)
    First, change contents of cow buffer and print all buffers. The change is reflected only in cow buffer (not in ro or rw) - as expected.
    Then, change contents of r/w buffer and print all buffers. The change is NOT observed in cow buffer, but reflected in ro and rw buffers (for Linux-IA64). I tried the same program in Linux-X86 and the change is reflected in all buffers (including cow buffer).
    I used JDK 1.4.2_03 for compiling and running. The doc for MappedByteBuffer says
    "The content of a mapped byte buffer can change at any time, for example if the content of the corresponding region of the mapped file is changed by this program or another. Whether or not such changes occur, and when they occur, is operating-system dependent and therefore unspecified."
    Is this behaviour acceptable? Is this observed in any other platform?
    I think Java NIO leaves it to the O/S and JVM is not doing anything here (as different from java.io). This could probably result in inconsistent behaviour across platforms (though it improves performance)
    Please let me know your thoughts.

    My thought is that you have posted this to the wrong forum.

  • Selecting between java.io and java.nio

    Hi,
    I'm a bit confused between java.io and java.nio. What sre the major differences between these two?
    In areas are these best applicable?

    The java.nio package improves on the basic Java I/O that was available prior to JDK 1.4.
    It is designed to interoperate more natively with the underlying file handles (sockets, open files etc) to achieve better performance.
    The improvements include true non-blocking I/O, better buffer management, character-set support, channels (similar to Occam's channels) and selectors, and some other ancillery stuff. Most of these classes are designed to be inherently threadsafe.
    There are some examples here:
    http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/index.html
    However, if you are still a beginner with file or network I/O, its better if you start with the simple I/O first. You'll appreciate the NIO improvements better afterwards.

Maybe you are looking for