use of io.minio.errors.InvalidEndpointException in project SBK by kmgowda.
the class MinIO method openStorage.
@Override
public void openStorage(final ParameterOptions params) throws IOException {
try {
// Create a minioClient with the MinIO Server name, Port, Access key and Secret key.
mclient = new MinioClient(config.url, config.accessKey, config.secretKey);
// Check if the bucket already exists.
boolean isExist = mclient.bucketExists(config.bucketName);
if (isExist) {
Printer.log.info("Bucket '" + config.bucketName + "' already exists.");
if (config.reCreate && params.getWritersCount() > 0) {
Printer.log.info("Deleting the Bucket: " + config.bucketName);
// Delete all existing objects first
final Iterable<Result<Item>> results = mclient.listObjects(config.bucketName, config.bucketName, false);
Item item;
for (Result<Item> result : results) {
item = result.get();
Printer.log.info("Deleting the object: " + item.objectName());
mclient.removeObject(config.bucketName, item.objectName());
}
mclient.removeBucket(config.bucketName);
isExist = false;
}
} else if (params.getWritersCount() < 1) {
throw new IOException("Bucket '" + config.bucketName + "' does not exist.");
} else {
Printer.log.info("Bucket '" + config.bucketName + "' does not exist.");
}
if (!isExist && params.getWritersCount() > 0) {
Printer.log.info("Creating the Bucket: " + config.bucketName);
mclient.makeBucket(config.bucketName);
}
} catch (InvalidPortException | InvalidEndpointException | org.xmlpull.v1.XmlPullParserException | InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | ErrorResponseException | RegionConflictException | NoResponseException | InternalException | InvalidArgumentException ex) {
throw new IOException(ex);
}
}
use of io.minio.errors.InvalidEndpointException in project molgenis by molgenis.
the class MinioClientFactoryImpl method createClient.
@Override
@Retryable(value = { IOException.class }, maxAttempts = 10, backoff = @Backoff(delay = 1000, multiplier = 2.0))
public MinioClient createClient() throws IOException {
MinioClient minioClient;
try {
minioClient = new MinioClient(minioEndpoint, minioAccessKey, minioSecretKey, region);
} catch (InvalidEndpointException | InvalidPortException e) {
throw new IllegalArgumentException(e);
}
LOG.debug("Connecting to Minio on '{}' ...", minioEndpoint);
createBucketIfNotExists(minioClient, bucketName, region);
LOG.info("Connected to Minio on '{}'", minioEndpoint);
return minioClient;
}
use of io.minio.errors.InvalidEndpointException in project universal-db by teamapps-org.
the class CachingS3FileStore method connect.
private void connect() {
try {
minioClient = new MinioClient(url, accessKey, secretKey);
createBucket(bucketName);
} catch (InvalidEndpointException | InvalidPortException e) {
e.printStackTrace();
}
}
use of io.minio.errors.InvalidEndpointException in project cogcomp-nlp by CogComp.
the class TransliterationAnnotator method initialize.
@Override
public void initialize(ResourceManager rm) {
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getDirectory("org.cogcomp.transliteration", "transliteration-models", 1.3, false);
String modelPath = f.getAbsolutePath() + File.separator + "transliteration-models-oct-2017" + File.separator + "probs-" + lang.getCode() + ".txt";
if (new File(modelPath).exists()) {
logger.info("Loading transliteration models for language: " + lang + " from " + modelPath);
model = new SPModel(modelPath);
model.setMaxCandidates(1);
} else {
logger.error("Model for language: " + lang + " don't exist: " + modelPath);
}
} catch (IOException | InvalidEndpointException | DatastoreException | InvalidPortException e) {
e.printStackTrace();
}
}
use of io.minio.errors.InvalidEndpointException in project cogcomp-nlp by CogComp.
the class TreeGazetteers method init.
/**
* init all the gazetters, mangle each term in a variety of ways.
*
* @param pathToDictionaries the path to the gazetteers.
* @param phrase_length the max length of the phrases we will consider.
* @throws IOException
*/
private void init(int phrase_length, String pathToDictionaries, final Language language) throws IOException {
try {
// check the local file system for it.
File gazDirectory = new File(pathToDictionaries);
String pathToLists = gazDirectory.getPath() + File.separator + "gazetteers" + File.separator + "gazetteers-list.txt";
InputStream stream = ResourceUtilities.loadResource(pathToLists);
if (stream == null) {
logger.info("Loading gazetteers from \"" + pathToLists + "\" using the Minio cache.");
// not in file system or classpath, try Minio.
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
gazDirectory = dsNoCredentials.getDirectory("org.cogcomp.gazetteers", "gazetteers", 1.6, false);
stream = new FileInputStream(gazDirectory.getPath() + File.separator + "gazetteers" + File.separator + "gazetteers-list.txt");
} else {
logger.info("Loading gazetteers from \"" + pathToLists + "\" from the local file system.");
}
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String line;
ArrayList<String> filenames = new ArrayList<>();
while ((line = br.readLine()) != null) filenames.add(line);
// init the dictionaries.
dictionaries = new ArrayList<>(filenames.size());
dictionariesIgnoreCase = new ArrayList<>(filenames.size());
GazetteerTree gaz = new GazetteerTree(phrase_length, new StringSplitterInterface() {
@Override
public String[] split(String line) {
// character tokenization for Chinese
if (language == Language.Chinese) {
String[] chars = new String[line.length()];
for (int i = 0; i < line.length(); i++) chars[i] = String.valueOf(line.charAt(i));
return chars;
} else
return line.split("[\\s]+");
}
@Override
public final String normalize(String term) {
return term;
}
});
GazetteerTree gazIC = new GazetteerTree(phrase_length, new StringSplitterInterface() {
@Override
public String[] split(String line) {
String tmp = line.toLowerCase();
if (tmp.equals("in") || tmp.equals("on") || tmp.equals("us") || tmp.equals("or") || tmp.equals("am"))
return new String[0];
else {
// character tokenization for Chinese
if (language == Language.Chinese) {
String[] chars = new String[line.length()];
for (int i = 0; i < line.length(); i++) chars[i] = String.valueOf(line.charAt(i));
return chars;
} else
return normalize(line).split("[\\s]+");
}
}
@Override
public String normalize(String term) {
return term.toLowerCase();
}
});
// for each dictionary, compile each of the gaz trees for each phrase permutation.
for (String file : filenames) {
String fileName = gazDirectory.getAbsolutePath() + File.separator + file;
gaz.readDictionary(file, "", ResourceUtilities.loadResource(fileName));
gazIC.readDictionary(file, "(IC)", ResourceUtilities.loadResource(fileName));
}
gaz.trimToSize();
gazIC.trimToSize();
dictionaries.add(gaz);
dictionariesIgnoreCase.add(gazIC);
logger.info("Gazetteers from \"" + pathToLists + "\" are loaded.");
} catch (InvalidPortException | InvalidEndpointException e) {
e.printStackTrace();
} catch (DatastoreException e) {
e.printStackTrace();
}
}
Aggregations