Skip to content
Snippets Groups Projects
Commit 2df2236d authored by pkupczyk's avatar pkupczyk
Browse files

SP-824 / BIS-518 : Logs - improve logging of service calls

SVN: 29682
parent bb259c7b
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,11 @@ public class ControlDirectoryEventFeed implements IEventFeed ...@@ -43,6 +43,11 @@ public class ControlDirectoryEventFeed implements IEventFeed
{ {
List<String> events = new ArrayList<String>(); List<String> events = new ArrayList<String>();
if (controlDir.exists() == false || controlDir.isDirectory() == false)
{
return events;
}
List<File> files = Arrays.asList(controlDir.listFiles()); List<File> files = Arrays.asList(controlDir.listFiles());
Collections.sort(files, new Comparator<File>() Collections.sort(files, new Comparator<File>()
......
...@@ -18,8 +18,8 @@ package ch.systemsx.cisd.openbis.common.controlfile; ...@@ -18,8 +18,8 @@ package ch.systemsx.cisd.openbis.common.controlfile;
import java.io.File; import java.io.File;
import ch.systemsx.cisd.common.filesystem.control.ControlDirectoryEventFeed;
import ch.systemsx.cisd.common.filesystem.control.DelayingDecorator; import ch.systemsx.cisd.common.filesystem.control.DelayingDecorator;
import ch.systemsx.cisd.common.filesystem.control.FileSystemBasedEventProvider;
import ch.systemsx.cisd.common.filesystem.control.IValueFilter; import ch.systemsx.cisd.common.filesystem.control.IValueFilter;
import ch.systemsx.cisd.common.filesystem.control.ParameterMap; import ch.systemsx.cisd.common.filesystem.control.ParameterMap;
...@@ -49,7 +49,7 @@ public class ControlFileReader ...@@ -49,7 +49,7 @@ public class ControlFileReader
public ControlFileReader(File controlFileDirectory, long controlFileMaxDelay) public ControlFileReader(File controlFileDirectory, long controlFileMaxDelay)
{ {
parameterMap = parameterMap =
new ParameterMap(new DelayingDecorator(controlFileMaxDelay, new FileSystemBasedEventProvider(controlFileDirectory))); new ParameterMap(new DelayingDecorator(controlFileMaxDelay, new ControlDirectoryEventFeed(controlFileDirectory)));
parameterMap.addParameter(LOG_SERVICE_CALL_START, OFF, new IValueFilter() parameterMap.addParameter(LOG_SERVICE_CALL_START, OFF, new IValueFilter()
{ {
......
...@@ -47,7 +47,7 @@ public class ControlFileReaderTest ...@@ -47,7 +47,7 @@ public class ControlFileReaderTest
} }
@Test @Test
public void test() throws IOException public void testSwitchOnAndOff() throws IOException
{ {
ControlFileReader reader = new ControlFileReader(getControlFileDirectory(), -1); ControlFileReader reader = new ControlFileReader(getControlFileDirectory(), -1);
Assert.assertFalse(reader.isLogServiceCallStartEnabled()); Assert.assertFalse(reader.isLogServiceCallStartEnabled());
...@@ -59,6 +59,19 @@ public class ControlFileReaderTest ...@@ -59,6 +59,19 @@ public class ControlFileReaderTest
Assert.assertFalse(reader.isLogServiceCallStartEnabled()); Assert.assertFalse(reader.isLogServiceCallStartEnabled());
} }
@Test
public void testWithNotExistingControlFileDirectory() throws IOException
{
ControlFileReader reader = new ControlFileReader(new File(getControlFileDirectory(), "notExisting"), -1);
Assert.assertFalse(reader.isLogServiceCallStartEnabled());
new File(getControlFileDirectory(), "log-service-call-start-on").createNewFile();
Assert.assertFalse(reader.isLogServiceCallStartEnabled());
new File(getControlFileDirectory(), "log-service-call-start-off").createNewFile();
Assert.assertFalse(reader.isLogServiceCallStartEnabled());
}
private File getControlFileDirectory() private File getControlFileDirectory()
{ {
TestResources resources = new TestResources(getClass()); TestResources resources = new TestResources(getClass());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment