frostfs-sdk-java/client/src/main/java/info/FrostFS/sdk/Main.java

54 lines
2.2 KiB
Java
Raw Normal View History

package info.FrostFS.sdk;
import info.FrostFS.sdk.enums.BasicAcl;
import info.FrostFS.sdk.enums.ObjectType;
import info.FrostFS.sdk.jdo.*;
import info.FrostFS.sdk.jdo.netmap.PlacementPolicy;
import info.FrostFS.sdk.jdo.netmap.Replica;
import info.FrostFS.sdk.services.FrostFSClient;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
ClientSettings clientSettings = new ClientSettings("KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq", "http://localhost:8080");
FrostFSClient frostFSClient = new FrostFSClient(clientSettings);
/*
var res2 = frostFSClient.searchObjectsAsync(new ContainerId("EQGx2QeYHJb53uRwYGzcQaW191sZpdNrjutk6veUSV2R"));
*/
ObjectFrostFs res3 = frostFSClient
.getObjectAsync(new ContainerId("EQGx2QeYHJb53uRwYGzcQaW191sZpdNrjutk6veUSV2R"), new ObjectId("85orCLKSu3X1jGiTFmwmTUsBU88RBARNwuRwrEy5pyww"));
var ttttt = frostFSClient.getNetworkSettingsAsync();
Container container2 = frostFSClient.getContainerAsync(new ContainerId("EQGx2QeYHJb53uRwYGzcQaW191sZpdNrjutk6veUSV2R"));
var placementPolicy = new PlacementPolicy(true, new Replica[]{new Replica(1)});
var containerId = frostFSClient.createContainerAsync(new Container(BasicAcl.PUBLIC_RW, placementPolicy));
Thread.sleep(1000);
FileInputStream file = null;
try {
file = new FileInputStream("/home/ori/Desktop/cat.jpg");
var cat = new ObjectHeader(containerId, ObjectType.REGULAR, new ObjectAttribute[]{new ObjectAttribute("Filename", "cat.jpg")});
frostFSClient.putObjectAsync(cat, file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
var res = frostFSClient.searchObjectsAsync(containerId);
Container container = frostFSClient.getContainerAsync(containerId);
List<ContainerId> containerIds = frostFSClient.listContainersAsync();
/*
frostFSClient.deleteContainerAsync(containerId);
*/
containerIds = frostFSClient.listContainersAsync();
System.out.println();
}
}