My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SectorJNI  
Using Java with Sector
Featured, Phase-Requirements
Updated Oct 16, 2009 by collinbe...@gmail.com

A Java Native Interface to the Sector File System

Collin Bennett, Robert Grossman, Jonathan Seidman

Since Sector is implemented in C++, writing clients against the Sector client API requires familiarity with C++ coding. This presents a potential barrier to non-C++ developers. Sector JNI is a Java Native Interface to the Sector C++ client API, which allows Java developers to write Sector clients using pure Java. Sector JNI supports the full Sector client API functionality - e.g.

  • mkdir,
  • remove,
  • list,
  • stat,
  • etc.

A real-world application of using JNI / NIO to access Sector is the implementation of the Hadoop File System which uses Sector for the back end. This is being contributed to Hadoop and more information can be found at SectorFileSystem.

Here is sample Java code which can create a new file on the Sector File System:

int status = 0;
SectorJniClient client = new SectorJniClient();
String path = "/new_file_test.dat";
        
try {
    status = client.sectorInit( host, port );
    status = client.sectorLogin( user, pass, certPath );
    long filehandle = client.sectorOpenFile( path, SectorJniClient.WRITE );
    client.sectorCloseFile( filehandle );
    SNode snode = client.sectorStat( path );
} catch( IOException e ) {
    System.out.println( "Caught IOException during testOpenNew(): " + e.getMessage() );
} finally {
    client.sectorLogout();
    status = client.sectorCloseFS();
}

SectorJNI has been contributed to Sector and is available on that project's Sourceforge site as a download or from source control.


Sign in to add a comment
Powered by Google Project Hosting