ShardUtils
Utility methods to have a repository distributed on several disks
Methods
setCurrentShard
Description:
Method | Return values | Description |
---|---|---|
setCurrentShard(Long shardId) |
void |
Set the current shard. |
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
Long shardId = new Long(1);
shardUtils.setCurrentShard(shardId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createShardDirs
Description:
Method | Return values | Description |
---|---|---|
createShardDirs(Long shardId) |
void |
Create new shard folder |
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
Long shardId = new Long(1);
shardUtils.createShardDirs(shardId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
changeNodeShard
Description:
Method | Return values | Description |
---|---|---|
changeNodeShard(String uuid, Long newShard) |
void |
Change shard of a node. |
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
Long newShardId = new Long(2);
shardUtils.changeNodeShard("e2391b01-ce10-42c7-94a9-b0d6b394048e", newShardId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getShardIds
Description:
Method | Return values | Description |
---|---|---|
getShardIds() |
List<Long> |
Get the shard ids. |
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
for (long id : shardUtils.getShardIds()) {
System.out.println(id);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getShardSize
Description:
Method | Return values | Description |
---|---|---|
getShardSize(Long shardId) |
Long |
Get the size of a shard. |
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
Long shardId = new Long(1);
System.out.println(shardUtils.getShardSize(shardId));
} catch (Exception e) {
e.printStackTrace();
}
}
}
getShardPaths
Description:
Method | Return values | Description |
---|---|---|
getShardPaths(Long shardId) |
List<String> |
Get the path of a shard. |
Example:
package com.openkm;
import java.util.List;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
Long shardId = new Long(1);
List<String> list = shardUtils.getShardPaths(shardId);
for (String path : list) {
System.out.println(path);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getShards
Description:
Method | Return values | Description |
---|---|---|
getShards() |
List<Shard> |
Get the shards |
Example:
package com.openkm;
import java.util.List;
import com.openkm.db.bean.Shard;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
List<Shard> list = shardUtils.getShards();
for (Shard shard : list) {
System.out.println(shard);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getShardFolders
Description:
Method | Return values | Description |
---|---|---|
getShardFolders() |
List<File> |
Get shard folders. |
Example:
package com.openkm;
import java.io.File;
import java.util.List;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ShardUtils;
public class Test {
public static void main(String[] args) {
try {
ShardUtils shardUtils = ContextWrapper.getContext().getBean(ShardUtils.class);
List<File> list = shardUtils.getShardFolders();
for (File file : list) {
System.out.println(file.getPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}