Author: chirino
Date: Mon Nov 16 22:48:28 2009
New Revision: 881020
URL: http://svn.apache.org/viewvc?rev=881020&view=rev
Log:
porting to linux
Modified:
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/IO.java
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/configure.ac
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/src/activemq-syscall.h
activemq/sandbox/activemq-apollo/activemq-syscall/src/test/java/org/apache/activemq/syscall/AIOTest.java
Modified:
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/IO.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/IO.java?rev=881020&r1=881019&r2=881020&view=diff
==============================================================================
---
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/IO.java
(original)
+++
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/IO.java
Mon Nov 16 22:48:28 2009
@@ -55,16 +55,6 @@
@JniField(flags={CONSTANT})
public static int O_EXCL;
@JniField(flags={CONSTANT})
- public static int O_SHLOCK;
- @JniField(flags={CONSTANT})
- public static int O_EXLOCK;
- @JniField(flags={CONSTANT})
- public static int O_NOFOLLOW;
- @JniField(flags={CONSTANT})
- public static int O_SYMLINK;
- @JniField(flags={CONSTANT})
- public static int O_EVTONLY;
- @JniField(flags={CONSTANT})
public static int O_ASYNC;
@JniField(flags={CONSTANT})
@@ -116,26 +106,6 @@
@JniField(flags={CONSTANT})
public static int F_SETOWN;
@JniField(flags={CONSTANT})
- public static int F_GETPATH;
- @JniField(flags={CONSTANT})
- public static int F_PREALLOCATE;
- @JniField(flags={CONSTANT})
- public static int F_SETSIZE;
- @JniField(flags={CONSTANT})
- public static int F_RDADVISE;
- @JniField(flags={CONSTANT})
- public static int F_RDAHEAD;
- @JniField(flags={CONSTANT})
- public static int F_READBOOTSTRAP;
- @JniField(flags={CONSTANT})
- public static int F_WRITEBOOTSTRAP;
- @JniField(flags={CONSTANT})
- public static int F_NOCACHE;
- @JniField(flags={CONSTANT})
- public static int F_LOG2PHYS;
- @JniField(flags={CONSTANT})
- public static int F_FULLFSYNC;
- @JniField(flags={CONSTANT})
public static int F_GETLK;
@JniField(flags={CONSTANT})
public static int F_SETLK;
Modified:
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/configure.ac
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/configure.ac?rev=881020&r1=881019&r2=881020&view=diff
==============================================================================
---
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/configure.ac
(original)
+++
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/configure.ac
Mon Nov 16 22:48:28 2009
@@ -53,6 +53,7 @@
])
AC_CHECK_HEADER([sys/errno.h],[AC_DEFINE([HAVE_SYS_ERRNO_H], [1], [Define to 1
if you have the <sys/errno.h> header file.])])
+AC_CHECK_HEADER([sys/stat.h],[AC_DEFINE([HAVE_SYS_STAT_H], [1], [Define to 1
if you have the <sys/stat.h> header file.])])
CFLAGS="$CFLAGS $JNI_EXTRA_CFLAGS"
LDFLAGS="$LDFLAGS $JNI_EXTRA_LDFLAGS -release $PACKAGE_VERSION"
Modified:
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/src/activemq-syscall.h
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/src/activemq-syscall.h?rev=881020&r1=881019&r2=881020&view=diff
==============================================================================
---
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/src/activemq-syscall.h
(original)
+++
activemq/sandbox/activemq-apollo/activemq-syscall/src/main/native-package/src/activemq-syscall.h
Mon Nov 16 22:48:28 2009
@@ -32,5 +32,9 @@
#include <sys/errno.h>
#endif
+#ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+#endif
+
#include <fcntl.h>
#endif /* INCLUDED_ACTIVEMQ_SYSCALL_H */
Modified:
activemq/sandbox/activemq-apollo/activemq-syscall/src/test/java/org/apache/activemq/syscall/AIOTest.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-syscall/src/test/java/org/apache/activemq/syscall/AIOTest.java?rev=881020&r1=881019&r2=881020&view=diff
==============================================================================
---
activemq/sandbox/activemq-apollo/activemq-syscall/src/test/java/org/apache/activemq/syscall/AIOTest.java
(original)
+++
activemq/sandbox/activemq-apollo/activemq-syscall/src/test/java/org/apache/activemq/syscall/AIOTest.java
Mon Nov 16 22:48:28 2009
@@ -3,6 +3,8 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.activemq.syscall.AIO.aiocb;
@@ -59,15 +61,36 @@
File file = new File("target/test-data/test.data");
file.getParentFile().mkdirs();
- // Setup a buffer holds the data that we will be writing..
+ // Clear out the data in the file.
StringBuffer sb = new StringBuffer();
for( int i=0; i < 1024*4; i++ ) {
- sb.append((char)('a'+(i%26)));
+ sb.append(' ');
}
+ storeContent(file, sb.toString());
+
+ // Setup a buffer holds the data that we will be writing..
+ sb = new StringBuffer();
+ for( int i=0; i < 1024*4; i++ ) {
+ sb.append((char)('a'+(i%26)));
+ }
+
String expected = sb.toString();
NativeBuffer writeBuffer = nativeBuffer(expected);
- long aiocbp = calloc(aiocb.SIZEOF, 1);
+
+ long aiocbp = malloc(aiocb.SIZEOF);
+ System.out.println("Allocated cb of size: "+aiocb.SIZEOF+", at
"+String.format("%x", aiocbp));
+ memset(aiocbp, 0, aiocb.SIZEOF); // clear out the memory..
+
+ // Lets read it to verify it's been cleared.
+ aiocb cb = new aiocb();
+ aiocb.memmove(cb, aiocbp, aiocb.SIZEOF);
+
+ assertEquals(0, cb.aio_buf);
+ assertEquals(0, cb.aio_fildes);
+ assertEquals(0, cb.aio_nbytes);
+ assertEquals(0, cb.aio_offset);
+
try {
// open the file...
int mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
@@ -75,7 +98,6 @@
checkrc(fd);
// Create a control block..
- aiocb cb = new aiocb();
// The where:
cb.aio_fildes = fd;
cb.aio_offset = 0;
@@ -87,6 +109,7 @@
aiocb.memmove(aiocbp, cb, aiocb.SIZEOF);
// enqueue the async write..
+ System.out.println("before write cb at "+String.format("%x",
aiocbp));
checkrc(aio_write(aiocbp));
long blocks[] = new long[]{aiocbp};
@@ -116,6 +139,11 @@
}
// Read the file in and verify the contents is what we expect
+ String actual = loadContent(file);
+ assertEquals(expected, actual);
+ }
+
+ private String loadContent(File file) throws FileNotFoundException,
IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream is = new FileInputStream(file);
try {
@@ -127,12 +155,22 @@
is.close();
}
String actual = new String(baos.toByteArray());
- assertEquals(expected, actual);
+ return actual;
}
+ private void storeContent(File file, String content) throws
FileNotFoundException, IOException {
+ FileOutputStream os = new FileOutputStream(file);
+ try {
+ os.write(content.getBytes());
+ } finally {
+ os.close();
+ }
+ }
+
private void checkrc(int rc) throws IOException {
- if( rc==-1 )
+ if( rc==-1 ) {
throw new IOException("IO failure: "+string(strerror(errno())));
+ }
}
@Test