Search in sources :

Example 6 with InvalidEndpointException

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);
    }
}
Also used : InvalidBucketNameException(io.minio.errors.InvalidBucketNameException) InsufficientDataException(io.minio.errors.InsufficientDataException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidPortException(io.minio.errors.InvalidPortException) InvalidKeyException(java.security.InvalidKeyException) InvalidEndpointException(io.minio.errors.InvalidEndpointException) Result(io.minio.Result) InternalException(io.minio.errors.InternalException) RegionConflictException(io.minio.errors.RegionConflictException) Item(io.minio.messages.Item) InvalidArgumentException(io.minio.errors.InvalidArgumentException) MinioClient(io.minio.MinioClient) ErrorResponseException(io.minio.errors.ErrorResponseException) NoResponseException(io.minio.errors.NoResponseException)

Example 7 with InvalidEndpointException

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;
}
Also used : MinioClient(io.minio.MinioClient) InvalidPortException(io.minio.errors.InvalidPortException) InvalidEndpointException(io.minio.errors.InvalidEndpointException) Retryable(org.springframework.retry.annotation.Retryable)

Example 8 with InvalidEndpointException

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();
    }
}
Also used : MinioClient(io.minio.MinioClient) InvalidPortException(io.minio.errors.InvalidPortException) InvalidEndpointException(io.minio.errors.InvalidEndpointException)

Example 9 with InvalidEndpointException

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();
    }
}
Also used : Datastore(org.cogcomp.Datastore) SPModel(edu.illinois.cs.cogcomp.transliteration.SPModel) ResourceConfigurator(edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator) IOException(java.io.IOException) DatastoreException(org.cogcomp.DatastoreException) InvalidPortException(io.minio.errors.InvalidPortException) File(java.io.File) InvalidEndpointException(io.minio.errors.InvalidEndpointException)

Example 10 with InvalidEndpointException

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();
    }
}
Also used : ArrayList(java.util.ArrayList) ResourceConfigurator(edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator) DatastoreException(org.cogcomp.DatastoreException) InvalidPortException(io.minio.errors.InvalidPortException) InvalidEndpointException(io.minio.errors.InvalidEndpointException) Datastore(org.cogcomp.Datastore) StringSplitterInterface(edu.illinois.cs.cogcomp.ner.ExpressiveFeatures.GazetteerTree.StringSplitterInterface)

Aggregations

InvalidEndpointException (io.minio.errors.InvalidEndpointException)15 InvalidPortException (io.minio.errors.InvalidPortException)15 DatastoreException (org.cogcomp.DatastoreException)12 Datastore (org.cogcomp.Datastore)11 ResourceConfigurator (edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator)10 File (java.io.File)9 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)4 MinioClient (io.minio.MinioClient)3 FileNotFoundException (java.io.FileNotFoundException)3 JWNLException (net.didion.jwnl.JWNLException)3 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)2 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)2 WordNetManager (edu.illinois.cs.cogcomp.edison.utilities.WordNetManager)2 BrownClusters (edu.illinois.cs.cogcomp.ner.ExpressiveFeatures.BrownClusters)2 FlatGazetteers (edu.illinois.cs.cogcomp.ner.ExpressiveFeatures.FlatGazetteers)2 StringSplitterInterface (edu.illinois.cs.cogcomp.ner.ExpressiveFeatures.GazetteerTree.StringSplitterInterface)2 Gazetteers (edu.illinois.cs.cogcomp.ner.ExpressiveFeatures.Gazetteers)2 InFile (edu.illinois.cs.cogcomp.ner.IO.InFile)2 POSAnnotator (edu.illinois.cs.cogcomp.pos.POSAnnotator)2