Skip to content

Commit

Permalink
#1 io params
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Jun 15, 2017
1 parent a2f8b7e commit 4c93f1b
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.irods.jargon2.common.confg.enumz;

/**
* use standard or nio
*
* @author mcc
*
* https://thomaswabner.wordpress.com/2007/10/09/fast-stream-copy-using-javanio-channels/
*
*/
public enum EnumIoStyle {
NIO, Standard;

public static EnumIoStyle mapIoStyleToEnum(final String ioStyle) {
EnumIoStyle enumIoStyle = null;
for (EnumIoStyle enumValue : EnumIoStyle.values()) {
if (enumValue.toString().equals(ioStyle)) {
enumIoStyle = enumValue;
break;
}
}

return enumIoStyle;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
*
*/
/**
* Enumerations and constants for configuration data
*
* @author mcc
*
*/
package org.irods.jargon2.common.confg.enumz;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import java.util.concurrent.ConcurrentHashMap;

import org.irods.jargon2.common.confg.enumz.EnumIoStyle;

/**
* Defines global tuning and behavior properties. Properties are internally
* stored as a concurrent hashmap, allowing sharing of this properties class
Expand All @@ -16,6 +18,7 @@
public class CachedJargonProperties implements JargonProperties {

public static final String CONNECTION_TIMEOUT_IN_SECONDS = "connection.timeout";
public static final String IO_STYLE = "io.style";

private ConcurrentHashMap<String, String> propertiesCache = new ConcurrentHashMap<>();

Expand All @@ -41,6 +44,42 @@ public void setConnectionTimeoutInSeconds(int timeout) {
propertiesCache.put(CONNECTION_TIMEOUT_IN_SECONDS, String.valueOf(timeout));
}

@Override
public EnumIoStyle getEnumIoStyle() {
// TODO Auto-generated method stub
return null;
}

@Override
public void setEnumIoStyle(EnumIoStyle enumIoStyle) {
// TODO Auto-generated method stub

}

@Override
public boolean isUseNioDirect() {
// TODO Auto-generated method stub
return false;
}

@Override
public void setUseNioDirect(boolean useNioDirect) {
// TODO Auto-generated method stub

}

@Override
public boolean isUseFastChannelCopy() {
// TODO Auto-generated method stub
return false;
}

@Override
public void setUseFastChannelCopy(boolean useFastChannelCopy) {
// TODO Auto-generated method stub

}

private int valAsIntOrZero(final String key) {
String stringVal = propertiesCache.get(key);
if (stringVal == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,68 @@
package org.irods.jargon2.common.confg.props;

import org.irods.jargon2.common.confg.enumz.EnumIoStyle;

/**
* Interface for jargon
*
* @author mconway
*
*/
public interface JargonProperties {

/*
* iRODS connection properties
*/
int getConnectionTimeoutInSeconds();

void setConnectionTimeoutInSeconds(int connectionTimeoutInSeconds);

/*
* General i/o properties
*/

/**
* Get the configured io style
*
* @return {@link EnumIoStyle}
*/
EnumIoStyle getEnumIoStyle();

void setEnumIoStyle(EnumIoStyle enumIoStyle);

/*
* local file system i/o properties
*/

/**
* Check if using NIO direct buffers. Only active if NIO is the chosen IO
* mode
*
* @return <code>boolean</code> use nio direct
*/
boolean isUseNioDirect();

/**
* Set nio direct
*
* @param useNioDirect
* <code>boolean</code> if nio direct is to be used, otherwise an
* indirect byte buffer is used
*/
void setUseNioDirect(boolean useNioDirect);

/**
* Use fast channel copy between channels, only active if io style is nio
*
* @return <code>boolean</code> if using fast channel copy
*/
boolean isUseFastChannelCopy();

/**
* Set fast channel copy behavior
*
* @param useFastChannelCopy
*/
void setUseFastChannelCopy(boolean useFastChannelCopy);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.irods.jargon2.common.confg.enumz;

import org.junit.Assert;
import org.junit.Test;

public class EnumIoStyleTest {

@Test
public void testMapIoStyleToEnum() {
String test = EnumIoStyle.NIO.toString();
EnumIoStyle actual = EnumIoStyle.mapIoStyleToEnum(test);
Assert.assertNotNull("null enumIoStyle", actual);
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.irods.jargon2.utils.unittest;

import org.irods.jargon2.common.confg.enumz.EnumIoStyleTest;
import org.irods.jargon2.utils.exception.bundle.MessageUtilTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({ MessageUtilTest.class })
@SuiteClasses({ MessageUtilTest.class, EnumIoStyleTest.class })
public class AllTests {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
public class IOContext {

/**
* Reference to controlling properties
*/
private JargonProperties jargonProperties;

/**
Expand Down

0 comments on commit 4c93f1b

Please sign in to comment.