Skip to content
Snippets Groups Projects
Commit dae3a9e5 authored by ribeaudc's avatar ribeaudc
Browse files

[DMV-12] fix: - Dependency by moving 'RemoteFreeSpaceProvider' to 'common' package.

SVN: 6075
parent 286449e4
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ import ch.systemsx.cisd.common.exceptions.NotImplementedException; ...@@ -24,6 +24,7 @@ import ch.systemsx.cisd.common.exceptions.NotImplementedException;
import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.Status;
import ch.systemsx.cisd.common.highwatermark.FileWithHighwaterMark; import ch.systemsx.cisd.common.highwatermark.FileWithHighwaterMark;
import ch.systemsx.cisd.common.highwatermark.HighwaterMarkWatcher; import ch.systemsx.cisd.common.highwatermark.HighwaterMarkWatcher;
import ch.systemsx.cisd.common.highwatermark.RemoteFreeSpaceProvider;
import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.logging.ISimpleLogger;
import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.logging.LogFactory;
...@@ -32,7 +33,6 @@ import ch.systemsx.cisd.datamover.filesystem.intf.FileStore; ...@@ -32,7 +33,6 @@ import ch.systemsx.cisd.datamover.filesystem.intf.FileStore;
import ch.systemsx.cisd.datamover.filesystem.intf.IExtendedFileStore; import ch.systemsx.cisd.datamover.filesystem.intf.IExtendedFileStore;
import ch.systemsx.cisd.datamover.filesystem.intf.IFileSysOperationsFactory; import ch.systemsx.cisd.datamover.filesystem.intf.IFileSysOperationsFactory;
import ch.systemsx.cisd.datamover.filesystem.intf.IStoreCopier; import ch.systemsx.cisd.datamover.filesystem.intf.IStoreCopier;
import ch.systemsx.cisd.datamover.utils.RemoteFreeSpaceProvider;
/** /**
* @author Tomasz Pylak * @author Tomasz Pylak
......
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.datamover.utils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.highwatermark.HighwaterMarkWatcher.IFreeSpaceProvider;
import ch.systemsx.cisd.common.process.ProcessExecutionHelper;
import ch.systemsx.cisd.common.process.ProcessResult;
/**
* An <code>IFreeSpaceProvider</code> implementation for computing the free space on a remote
* computer.
*
* @author Christian Ribeaud
*/
public final class RemoteFreeSpaceProvider implements IFreeSpaceProvider
{
private final File sshExecutable;
private final String host;
public RemoteFreeSpaceProvider(final String host, final File sshExecutable)
{
this.host = host;
this.sshExecutable = sshExecutable;
}
//
// IFreeSpaceProvider
//
public final long freeSpaceKb(final File path) throws IOException
{
final List<String> command =
Arrays.asList(sshExecutable.getPath(), host, "df -k " + path.getPath() + "");
Logger rootLogger = Logger.getRootLogger();
System.out.println(command);
final ProcessResult processResult =
ProcessExecutionHelper.run(command, 2000L, rootLogger, rootLogger);
System.out.println(processResult.getProcessOutput());
return 0L;
}
}
\ No newline at end of file
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.datamover.utils;
import static org.testng.AssertJUnit.assertNotNull;
import java.io.File;
import java.io.IOException;
import org.testng.annotations.Test;
import ch.systemsx.cisd.common.utilities.OSUtilities;
/**
* Test cases for {@link RemoteFreeSpaceProvider}.
*
* @author Christian Ribeaud
*/
public final class RemoteFreeSpaceProviderTest
{
@Test(groups = "broken")
public final void testFreeSpaceKb() throws IOException
{
final File sshExecutable = OSUtilities.findExecutable("ssh");
assertNotNull(sshExecutable);
final RemoteFreeSpaceProvider freeSpaceProvider =
new RemoteFreeSpaceProvider("sprint-ob", sshExecutable);
System.out.println(freeSpaceProvider.freeSpaceKb(new File("/")));
}
}
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