Skip to content

Commit

Permalink
#1 working on nio impl and start of exception hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Mar 29, 2017
1 parent e315575 commit 23fc1f1
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 1 deletion.
22 changes: 22 additions & 0 deletions io-plugin-nio/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.irods</groupId>
<artifactId>jargon2</artifactId>
<version>4.3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>io-plugin-nio</artifactId>
<packaging>jar</packaging>
<description>NIO plugin for local file access</description>
<name>io-plugin-nio</name>
<dependencies>
<dependency>
<groupId>org.irods</groupId>
<artifactId>jargon2-core-if</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
*
*/
/**
* Implementation of core i/o plugin interfaces
*
* @author mconway
*
*/
package org.irods.jargon2.core.pub.io;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**()
*
*/
package org.irods.jargon2.core.pub.io.plugin.nio;

import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.file.Path;

import org.irods.jargon2.core.ioplugin.FileIOOperations;
import org.irods.jargon2.core.ioplugin.IOContext;
import org.irods.jargon2.core.ioplugin.IOMonitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* NIO implementation of file operations. These plug into protocol operations to
* manage access to the local file system and the streaming of the actual bytes
* between the client and iRODS. This sits below the actual protocol operations
*
* @author mconway
*
*/
public class NIOFileIOOperationsImpl implements FileIOOperations {

public static final Logger log = LoggerFactory.getLogger(NIOFileIOOperationsImpl.class);

/*
* (non-Javadoc)
*
* @see org.irods.jargon2.core.ioplugin.FileIOOperations#
* transferLocalFileToIrodsSingleBuffer(java.nio.file.Path,
* java.nio.channels.Channel, org.irods.jargon2.core.ioplugin.IOMonitor,
* org.irods.jargon2.core.ioplugin.IOContext)
*/
@Override
public void transferLocalFileToIrodsSingleBuffer(Path path, Channel channel, IOMonitor ioMonitor,
IOContext ioContext) {
log.info("transferLocalFileToIrodsSingleBuffer()");
if (path == null) {
throw new IllegalArgumentException("null path");
}

if (channel == null) {
throw new IllegalArgumentException("null channel");
}

log.info("path:{}", path);
log.info("channel:{}", channel);
log.info("ioMonitor:{}", ioMonitor);
log.info("ioContext:{}", ioContext);

FileChannel.open(path);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
*
*/
/**
* Plugin for nio implementation of operations between irods and local file
* system
*
* @author mconway
*
*/
package org.irods.jargon2.core.pub.io.plugin.nio;
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@
*/
public interface FileIOOperations {

/**
* Given a {@link Channel|, transfer the contents of the given file at the
* {@link Path}. This channel represents a connection to iRODS expecting a
* single buffer put
*
* @param localSourcePath
* {@link Path} representing a local source file
* @param irodsChannel
* {@link Channel} representing the iRODS agent in a state
* expecting to receive the local file data
* @param ioMonitor
* {@link IOMonitor}, or null if not needed, that can receive
* status updates
* @param ioContext
* {@link IOContext} that can be used to share information and
* signals between threads.
*/
public void transferLocalFileToIrodsSingleBuffer(final Path localSourcePath, final Channel irodsChannel,
final IOMonitor ioMonitor);
final IOMonitor ioMonitor, final IOContext ioContext);

}
11 changes: 11 additions & 0 deletions jargon2-core-util/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ How can we relate to jmx?
#### cache

Internal? Distributed?



# conventions

#### Logging

* WARN for eaten exceptions and soft errors
* INFO is for method names and params and responses
* DEBUG for internal logging of checkpoints within methods
* TRACE dumps protocol messages
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
*
*/
package org.irods.jargon2.exception;

/**
* Root of checked Jargon exception hierarchy
*
* @author mconway
*
*/
public class JargonException extends Exception {

/**
*
*/
private static final long serialVersionUID = 4061550775957048060L;

/**
*
*/
public JargonException() {
}

/**
* @param arg0
*/
public JargonException(String arg0) {
super(arg0);
}

/**
* @param arg0
*/
public JargonException(Throwable arg0) {
super(arg0);
}

/**
* @param arg0
* @param arg1
*/
public JargonException(String arg0, Throwable arg1) {
super(arg0, arg1);
}

/**
* @param arg0
* @param arg1
* @param arg2
* @param arg3
*/
public JargonException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
super(arg0, arg1, arg2, arg3);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
*
*/
package org.irods.jargon2.exception;

/**
* Base of runtime exception hierarchy
*
* @author mconway
*
*/
public class JargonRuntimeException extends RuntimeException {

/**
* iRODS error code, if available
*/
private int irodsErrorCode = 0;

/**
*
*/
private static final long serialVersionUID = 3540887186451328323L;

/**
*
*/
public JargonRuntimeException() {
}

/**
* @param arg0
*/
public JargonRuntimeException(String arg0) {
super(arg0);
}

/**
* @param arg0
*/
public JargonRuntimeException(Throwable arg0) {
super(arg0);
}

/**
* @param arg0
* @param arg1
*/
public JargonRuntimeException(String arg0, Throwable arg1) {
super(arg0, arg1);
}

/**
* @param arg0
* @param arg1
* @param arg2
* @param arg3
*/
public JargonRuntimeException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
super(arg0, arg1, arg2, arg3);
}

public int getIrodsErrorCode() {
return irodsErrorCode;
}

public void setIrodsErrorCode(int irodsErrorCode) {
this.irodsErrorCode = irodsErrorCode;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
*
*/
/**
* I/O exceptions for file and network i/o conditions
*
* @author mconway
*
*/
package org.irods.jargon2.exception.io;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/**
* Root of Jargon2 exception hierarchy
*
* @author mconway
*
*/
package org.irods.jargon2.exception;
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
<modules>
<module>jargon2-core-if</module>
<module>jargon2-core-util</module>
<module>io-plugin-nio</module>
</modules>
</project>

0 comments on commit 23fc1f1

Please sign in to comment.