Search in sources :

Example 1 with MappingException

use of voldemort.xml.MappingException in project voldemort by voldemort.

the class MetadataStressTest method main.

public static void main(String[] args) throws Exception {
    if (args.length < 3) {
        System.err.println("java voldemort.performance.MetadataStressTest url iterations threads selectors");
        System.exit(-1);
    }
    String url = args[0];
    final int count = Integer.parseInt(args[1]);
    int numThreads = Integer.parseInt(args[2]);
    int numSelectors = args.length > 3 ? Integer.parseInt(args[3]) : 8;
    int timeoutSecs = args.length > 4 ? Integer.parseInt(args[4]) : 10;
    ExecutorService executor = Executors.newFixedThreadPool(numThreads, new ThreadFactory() {

        public Thread newThread(Runnable r) {
            Thread thread = new Thread(r);
            thread.setName("stress-test");
            return thread;
        }
    });
    try {
        final SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(url).setEnableLazy(false).setConnectionTimeout(timeoutSecs, TimeUnit.SECONDS).setSocketTimeout(timeoutSecs, TimeUnit.SECONDS).setMaxThreads(numThreads).setSelectors(numSelectors));
        for (int i = 0; i < numThreads; i++) {
            executor.submit(new Runnable() {

                public void run() {
                    for (int j = 0; j < count; j++) {
                        try {
                            String clusterXml = factory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
                            new ClusterMapper().readCluster(new StringReader(clusterXml));
                            String storesXml = factory.bootstrapMetadataWithRetries(MetadataStore.STORES_KEY);
                            new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml));
                            if (logger.isTraceEnabled())
                                logger.trace("ok " + j);
                        } catch (MappingException me) {
                            logger.fatal(me, me);
                            System.exit(-1);
                        } catch (Exception e) {
                            logger.error(e, e);
                        }
                    }
                }
            });
        }
    } finally {
        executor.shutdown();
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper) MappingException(voldemort.xml.MappingException) MappingException(voldemort.xml.MappingException) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) ExecutorService(java.util.concurrent.ExecutorService) StringReader(java.io.StringReader) ClientConfig(voldemort.client.ClientConfig)

Example 2 with MappingException

use of voldemort.xml.MappingException in project voldemort by voldemort.

the class RestUtils method parseSerializerDefinition.

private static SerializerDefinition parseSerializerDefinition(String serializerInfoXml, String elementName) {
    SAXBuilder builder = new SAXBuilder();
    try {
        Document doc = builder.build(new StringReader(serializerInfoXml));
        Element root = doc.getRootElement();
        Element serializerElement = root.getChild(elementName);
        return StoreDefinitionsMapper.readSerializer(serializerElement);
    } catch (JDOMException e) {
        throw new MappingException(e);
    } catch (IOException e) {
        throw new MappingException(e);
    }
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) StringReader(java.io.StringReader) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) MappingException(voldemort.xml.MappingException)

Aggregations

StringReader (java.io.StringReader)2 MappingException (voldemort.xml.MappingException)2 IOException (java.io.IOException)1 ExecutorService (java.util.concurrent.ExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1 JDOMException (org.jdom.JDOMException)1 SAXBuilder (org.jdom.input.SAXBuilder)1 ClientConfig (voldemort.client.ClientConfig)1 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)1 ClusterMapper (voldemort.xml.ClusterMapper)1 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)1