org.kie.commons.io.impl.cluster.FileSystemSyncLock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kie-commons-io Show documentation
Show all versions of kie-commons-io Show documentation
Set of utilities/facades for NIO.2
package org.kie.commons.io.impl.cluster;
import java.util.HashMap;
import java.util.Map;
import org.kie.commons.cluster.LockExecuteNotifyAsyncReleaseTemplate;
import org.kie.commons.java.nio.base.FileSystemId;
import org.kie.commons.java.nio.file.FileSystem;
import org.kie.commons.message.MessageType;
import static org.kie.commons.io.impl.cluster.ClusterMessageType.*;
public class FileSystemSyncLock extends LockExecuteNotifyAsyncReleaseTemplate {
private final FileSystem fileSystem;
public FileSystemSyncLock( final FileSystem fileSystem ) {
this.fileSystem = fileSystem;
}
@Override
public MessageType getMessageType() {
return SYNC_FS;
}
@Override
public Map buildContent() {
return new HashMap() {{
put( "fs_scheme", fileSystem.getRootDirectories().iterator().next().toUri().getScheme() );
put( "fs_id", ( (FileSystemId) fileSystem ).id() );
put( "fs_uri", fileSystem.toString() );
}};
}
}