public class FileSystemResourcesController extends Object
It controls the numbers of opened files, the storage size and the file system bandwidth. By default, there are no limits on the file system usage.
When an application tries to perform a file system operation (open/read/write), the controller checks if a file system limit setting is defined for the application and denies the operation if its execution will lead to exceeding one of the limits.
It also notifies the registered listeners when an operation is denied or when a limit is reached.
Constructor and Description |
---|
FileSystemResourcesController(Module module)
Creates an instance of the File System controller.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxOpenedFiles() |
long |
getMaxStorageSize() |
File[] |
getOpenedFiles()
Returns the current opened files.
|
long |
getStorageSize()
Returns the current storage size.
|
void |
onEnd(SandboxedModule module,
CloseFile closeFile,
boolean withSuccess)
Called when the execution of the given close file action is finished.
|
void |
onEnd(SandboxedModule module,
DeleteFile deleteFile,
boolean withSuccess)
Called when the execution of the given delete file action is finished.
|
void |
onEnd(SandboxedModule module,
OpenFile openFile,
boolean withSuccess)
Called when the execution of the given open file action is finished.
|
void |
onEnd(SandboxedModule module,
SetLengthRandomAccessFile setLengthFile,
boolean withSuccess)
Called when the execution of the given write file action is finished.
|
void |
onEnd(SandboxedModule module,
WriteFile writeFile,
boolean withSuccess)
Called when the execution of the given write file action is finished.
|
void |
onEnd(SandboxedModule module,
WriteRandomAccessFile writeFile,
boolean withSuccess)
Called when the execution of the given write file action is finished.
|
void |
onStart(SandboxedModule module,
CloseFile closeFile)
Called when the execution of the close file action is about to start.
|
void |
onStart(SandboxedModule module,
DeleteFile deleteFile)
Called when the execution of the delete file action is about to start.
|
void |
onStart(SandboxedModule module,
OpenFile openFile)
Called when the execution of the open file action is about to start.
|
void |
onStart(SandboxedModule module,
SetLengthRandomAccessFile setLengthFile)
Called when the execution of the write file action is about to start.
|
void |
onStart(SandboxedModule module,
WriteFile writeFile)
Called when the execution of the write file action is about to start.
|
void |
onStart(SandboxedModule module,
WriteRandomAccessFile writeFile)
Called when the execution of the write file action is about to start.
|
void |
reset()
Resets the controller.
|
void |
setMaxOpenedFiles(int maxOpenFiles)
Sets the maximum number of files allowed to be opened.
|
void |
setMaxStorageSize(long maxStorageSize)
Sets the maximum file system storage size (in bytes) allowed.
|
public FileSystemResourcesController(Module module)
module
- The module which performs the file system controls.public int getMaxOpenedFiles()
public long getMaxStorageSize()
public File[] getOpenedFiles()
public long getStorageSize()
public void onEnd(SandboxedModule module, CloseFile closeFile, boolean withSuccess)
module
- the application which performs the given close file action.closeFile
- the close file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onEnd(SandboxedModule module, DeleteFile deleteFile, boolean withSuccess)
module
- the module which performs the given delete file action.deleteFile
- the delete file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onEnd(SandboxedModule module, OpenFile openFile, boolean withSuccess)
module
- the module which performs the given open file action.openFile
- the open file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onEnd(SandboxedModule module, SetLengthRandomAccessFile setLengthFile, boolean withSuccess)
module
- the module which performs the given write file action.setLengthFile
- the write file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onEnd(SandboxedModule module, WriteFile writeFile, boolean withSuccess)
module
- the module which performs the given write file action.writeFile
- the write file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onEnd(SandboxedModule module, WriteRandomAccessFile writeFile, boolean withSuccess)
module
- the module which performs the given write file action.writeFile
- the write file action.withSuccess
- true if the execution of the action was ended with success; false otherwise.public void onStart(SandboxedModule module, CloseFile closeFile) throws SecurityException
It checks if the action is allowed to be executed.
module
- the module which performs the action.closeFile
- the close file action.SecurityException
- if the action is not allowed to be performed.public void onStart(SandboxedModule module, DeleteFile deleteFile) throws SecurityException
It checks if the action is allowed to be executed.
module
- the module which performs the delete file actiondeleteFile
- the delete file actionSecurityException
- if the action is not allowed to be performed.public void onStart(SandboxedModule module, OpenFile openFile) throws SecurityException
It checks if the action is allowed to be executed.
module
- the module which performs the action.openFile
- the open file action.SecurityException
- if the action is not allowed to be performed.public void onStart(SandboxedModule module, SetLengthRandomAccessFile setLengthFile) throws SecurityException
It checks if the action is allowed to be executed and throttles (delays) it if needed.
module
- the module which performs the write file action.setLengthFile
- the write file action.SecurityException
- if the action is not allowed to be performed.public void onStart(SandboxedModule module, WriteFile writeFile) throws SecurityException
It checks if the action is allowed to be executed and throttles (delays) it if needed.
module
- the module which performs the write file action.writeFile
- the write file action.SecurityException
- if the action is not allowed to be performed.public void onStart(SandboxedModule module, WriteRandomAccessFile writeFile) throws SecurityException
It checks if the action is allowed to be executed and throttles (delays) it if needed.
module
- the module which performs the write file action.writeFile
- the write file action.SecurityException
- if the action is not allowed to be performed.public void reset()
public void setMaxOpenedFiles(int maxOpenFiles)
maxOpenFiles
- the maximum number of files allowed to be opened. A negative value means there is no limit.public void setMaxStorageSize(long maxStorageSize)
maxStorageSize
- the maximum file system storage size. A negative value means there is no limit.