public final class NetUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.ThreadLocal<java.lang.String> |
CACHE_PERIOD
The default cache period to use when fetching files
|
static java.lang.String |
KNOWN_INVALID_PASSWORD |
static java.lang.String |
LOCAL_HOST_NAME
Local host name
|
static java.lang.String |
NETCLIENT_MAX_ACTIVE
The maximum number of connections per user/server
|
static java.lang.String |
NETCLIENT_MAX_WAIT_MS
Time in milliseconds to block for
|
static java.lang.String |
NETCLIENT_TEST_IDLE_MS
Time in milliseconds to check idle connections
|
static java.lang.ThreadLocal<java.lang.Boolean> |
REPAIR_MODE |
static java.util.concurrent.atomic.AtomicInteger |
RETRY_ATTEMPTS
the number of re-attempts on error
|
Modifier and Type | Method and Description |
---|---|
static NetClient |
borrowClient(java.lang.String url)
Borrow a Net client
|
static int |
borrowedClientCount()
The number of clients that are currently borrowed.
|
static boolean |
canConnect(java.lang.String uri)
Checks that we can connect to the server specified in the uri
|
static int |
clientPoolSize()
number of clients in the pool
|
static boolean |
exists(java.lang.String uri,
java.lang.String path)
Checks if the file denoted by the given URI physically exists.
|
static java.io.File |
fetchData(java.lang.String URLs,
java.lang.String path,
boolean haMode,
java.lang.String checksum)
fetch the file from the following location
|
static int |
getMaxWaitTime() |
static void |
invalidateClient(NetClient client)
Invalidate this Net client
|
static void |
removeData(java.lang.String URLs,
java.lang.String path)
remove the data from the locations specified.
|
static void |
renameData(java.lang.String URLs,
java.lang.String originalPath,
java.lang.String newPath)
rename the original file to the new name/location
|
static void |
retrieveData(java.lang.String URLs,
java.lang.String path,
java.io.File targetFile,
boolean haMode,
java.lang.String checksum)
Retrieve a file from a list of locations.
|
static java.lang.String[] |
retrieveFileList(java.lang.String url)
Retrieve a list of file names from a URL passed.
|
static void |
returnClient(NetClient client)
return the Net client to the pool
|
static void |
sendData(java.io.File rawFile,
java.lang.String URLs,
java.lang.String path)
Send the raw file to the locations listed.
|
static void |
setProgressListener(ProgressListener listener)
set the progress listener
|
public static final java.lang.String NETCLIENT_MAX_ACTIVE
public static final java.lang.String NETCLIENT_MAX_WAIT_MS
public static final java.lang.String NETCLIENT_TEST_IDLE_MS
public static final java.util.concurrent.atomic.AtomicInteger RETRY_ATTEMPTS
public static final java.lang.String KNOWN_INVALID_PASSWORD
public static final java.lang.ThreadLocal<java.lang.String> CACHE_PERIOD
public static final java.lang.String LOCAL_HOST_NAME
public static final java.lang.ThreadLocal<java.lang.Boolean> REPAIR_MODE
public static void sendData(@Nonnull java.io.File rawFile, @Nonnull java.lang.String URLs, @Nonnull java.lang.String path) throws java.lang.Exception
rawFile
- The raw file to sendURLs
- The list of URLspath
- The path to store the file.java.lang.Exception
- A serious problempublic static void removeData(@Nonnull java.lang.String URLs, @Nonnull java.lang.String path) throws java.lang.Exception
URLs
- The URLs for the file to be removed from.path
- The path of the file to be removed.java.lang.Exception
- A serious problem@CheckReturnValue @Nonnull public static java.io.File fetchData(@Nonnull java.lang.String URLs, @Nonnull java.lang.String path, boolean haMode, @Nullable java.lang.String checksum) throws java.lang.Exception
checksum
- the check sumURLs
- The locations to searchpath
- The file pathhaMode
- If in HA mode then if a file is missing we will sync between locations.java.lang.Exception
- A serious problempublic static void retrieveData(@Nonnull java.lang.String URLs, @Nonnull java.lang.String path, @Nonnull java.io.File targetFile, boolean haMode, @Nullable java.lang.String checksum) throws java.lang.Exception
targetFile
- the target file to receive tochecksum
- the checksumURLs
- The locations to searchpath
- The file pathhaMode
- If in HA ( High Availability) mode then we ensure that volumes that have multiple urls
have the file on all urls if it is found on one and not the others. This should not
happen as files are placed at all locations in a volume when the file is uploaded.java.lang.Exception
- A serious problempublic static void renameData(@Nonnull java.lang.String URLs, @Nonnull java.lang.String originalPath, @Nonnull java.lang.String newPath) throws java.lang.Exception
URLs
- the locations to rename the file atoriginalPath
- the path of the file to be renamednewPath
- the path to rename tojava.lang.Exception
- a serious problem@CheckReturnValue public static boolean exists(@Nonnull java.lang.String uri, @Nonnull java.lang.String path) throws java.lang.Exception
path
- the file pathuri
- the full uri to the filejava.lang.Exception
- failure to perform check@CheckReturnValue public static boolean canConnect(@Nonnull java.lang.String uri) throws java.lang.Exception
uri
- the full uri to the filejava.lang.Exception
- failure to perform check@CheckReturnValue @Nonnull public static NetClient borrowClient(@Nonnull java.lang.String url) throws java.lang.Exception
url
- The URL to connect tojava.lang.Exception
- could not create connection@CheckReturnValue @Nonnegative public static int borrowedClientCount()
@CheckReturnValue @Nonnegative public static int clientPoolSize() throws java.lang.Exception
java.lang.Exception
- doesn't support exceptionpublic static void returnClient(@Nullable NetClient client) throws java.lang.Exception
client
- The borrowed clientjava.lang.Exception
- client not borrowed.@CheckReturnValue @Nonnegative public static int getMaxWaitTime()
public static void invalidateClient(@Nullable NetClient client) throws java.lang.Exception
client
- The borrowed Net clientjava.lang.Exception
- A serious problempublic static void setProgressListener(@Nullable ProgressListener listener)
listener
- the listener@CheckReturnValue @Nonnull public static java.lang.String[] retrieveFileList(@Nonnull java.lang.String url) throws java.lang.Exception
url
- the URLjava.lang.Exception
- A serious problemstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.