Search in sources :

Example 26 with IHyracksClientConnection

use of org.apache.hyracks.api.client.IHyracksClientConnection in project asterixdb by apache.

the class VersionApiServletTest method testGet.

@Test
public void testGet() throws Exception {
    // Configures a test version api servlet.
    VersionApiServlet servlet = new VersionApiServlet(new ConcurrentHashMap<>(), new String[] { "/" });
    Map<String, String> propMap = new HashMap<>();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    PrintWriter outputWriter = new PrintWriter(outputStream);
    // Creates mocks.
    CcApplicationContext mockCtx = mock(CcApplicationContext.class);
    IServletRequest mockRequest = mock(IServletRequest.class);
    IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
    IServletResponse mockResponse = mock(IServletResponse.class);
    BuildProperties mockProperties = mock(BuildProperties.class);
    FullHttpRequest mockHttpRequest = mock(FullHttpRequest.class);
    // Put stuff in let map
    servlet.ctx().put(HYRACKS_CONNECTION_ATTR, mockHcc);
    servlet.ctx().put(ASTERIX_APP_CONTEXT_INFO_ATTR, mockCtx);
    // Sets up mock returns.
    when(mockResponse.writer()).thenReturn(outputWriter);
    when(mockRequest.getHttpRequest()).thenReturn(mockHttpRequest);
    when(mockHttpRequest.method()).thenReturn(HttpMethod.GET);
    when(mockCtx.getBuildProperties()).thenReturn(mockProperties);
    when(mockProperties.getAllProps()).thenReturn(propMap);
    propMap.put("git.build.user.email", "foo@bar.baz");
    propMap.put("git.build.host", "fulliautomatix");
    propMap.put("git.dirty", "true");
    propMap.put("git.remote.origin.url", "git@github.com:apache/incubator-asterixdb.git");
    propMap.put("git.closest.tag.name", "asterix-0.8.7-incubating");
    propMap.put("git.commit.id.describe-short", "asterix-0.8.7-incubating-19-dirty");
    propMap.put("git.commit.user.email", "foo@bar.baz");
    propMap.put("git.commit.time", "21.10.2015 @ 23:36:41 PDT");
    propMap.put("git.commit.message.full", "ASTERIXDB-1045: fix log file reading during recovery\n\nChange-Id: Ic83ee1dd2d7ba88180c25f4ec6c7aa8d0a5a7162\nReviewed-on: https://asterix-gerrit.ics.uci.edu/465\nTested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>");
    propMap.put("git.build.version", "0.8.8-SNAPSHOT");
    propMap.put("git.commit.message.short", "ASTERIXDB-1045: fix log file reading during recovery");
    propMap.put("git.commit.id.abbrev", "e1dad19");
    propMap.put("git.branch", "foo/bar");
    propMap.put("git.build.user.name", "Asterix");
    propMap.put("git.closest.tag.commit.count", "19");
    propMap.put("git.commit.id.describe", "asterix-0.8.7-incubating-19-ge1dad19-dirty");
    propMap.put("git.commit.id", "e1dad1984640517366a7e73e323c9de27b0676f7");
    propMap.put("git.tags", "");
    propMap.put("git.build.time", "22.10.2015 @ 17:11:07 PDT");
    propMap.put("git.commit.user.name", "Obelix");
    // Calls VersionAPIServlet.formResponseObject.
    servlet.handle(mockRequest, mockResponse);
    // Constructs the actual response.
    ObjectMapper om = new ObjectMapper();
    ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toByteArray());
    ObjectNode expectedResponse = om.createObjectNode();
    for (Map.Entry<String, String> e : propMap.entrySet()) {
        expectedResponse.put(e.getKey(), e.getValue());
    }
    // Checks the response contains all the expected keys.
    Assert.assertEquals(actualResponse.toString(), expectedResponse.toString());
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) VersionApiServlet(org.apache.asterix.api.http.server.VersionApiServlet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IServletRequest(org.apache.hyracks.http.api.IServletRequest) BuildProperties(org.apache.asterix.common.config.BuildProperties) CcApplicationContext(org.apache.asterix.runtime.utils.CcApplicationContext) IServletResponse(org.apache.hyracks.http.api.IServletResponse) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) SqlppExecutionTest(org.apache.asterix.test.runtime.SqlppExecutionTest)

Example 27 with IHyracksClientConnection

use of org.apache.hyracks.api.client.IHyracksClientConnection in project asterixdb by apache.

the class SecondaryIndexSearchExample method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(options);
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job);
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println(start + " " + end + " " + (end - start));
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Example 28 with IHyracksClientConnection

use of org.apache.hyracks.api.client.IHyracksClientConnection in project asterixdb by apache.

the class PrimaryIndexBulkLoadExample method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(options);
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job);
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println(start + " " + end + " " + (end - start));
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Example 29 with IHyracksClientConnection

use of org.apache.hyracks.api.client.IHyracksClientConnection in project asterixdb by apache.

the class PrimaryIndexSearchExample method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(options);
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job);
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println(start + " " + end + " " + (end - start));
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Example 30 with IHyracksClientConnection

use of org.apache.hyracks.api.client.IHyracksClientConnection in project asterixdb by apache.

the class Sort method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    if (args.length == 0) {
        parser.printUsage(System.err);
        return;
    }
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(parseFileSplits(options.inFileOrderSplits), parseFileSplits(options.outFileSplits), options.memBufferAlg, options.frameLimit, options.frameSize, options.topK, options.usingHeapSorter);
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job, options.profile ? EnumSet.of(JobFlag.PROFILE_RUNTIME) : EnumSet.noneOf(JobFlag.class));
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println("finished in:" + (end - start) + "ms");
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Aggregations

IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)30 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)13 JobId (org.apache.hyracks.api.job.JobId)13 JobSpecification (org.apache.hyracks.api.job.JobSpecification)11 CmdLineParser (org.kohsuke.args4j.CmdLineParser)10 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)8 PrintWriter (java.io.PrintWriter)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 IOException (java.io.IOException)7 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 AsterixException (org.apache.asterix.common.exceptions.AsterixException)3 IServletRequest (org.apache.hyracks.http.api.IServletRequest)3 IServletResponse (org.apache.hyracks.http.api.IServletResponse)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Date (java.util.Date)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2