Package com.cloudera.flume.master

Examples of com.cloudera.flume.master.Command


        list.add(tok.nextToken());
      }
    }

    String[] strArgs = list.toArray(new String[0]);
    return new Command(cmd, strArgs);

  }
View Full Code Here


  /**
   * Build a command for the command manager.
   */
  public Command toCommand() {
    return new Command("refresh", node);
  }
View Full Code Here

    assertEquals(end.state, start.state);
  }

  @Test
  public void testAvroCommandConversion() {
    Command start = new Command("here", "is", "a", "command");
    FlumeMasterCommandAvro middle = MasterAdminServerAvro.commandToAvro(start);
    assertEquals("here", middle.command.toString());
    assertEquals(3, middle.arguments.size());
    int index = 0;
    for (CharSequence u : middle.arguments) {
      switch (index) {
      case 0:
        assertEquals("is", u.toString());
        break;
      case 1:
        assertEquals("a", u.toString());
        break;
      case 2:
        assertEquals("command", u.toString());
        break;
      }
      index++;
    }
    Command end = MasterAdminServerAvro.commandFromAvro(middle);
    assertEquals("here", end.getCommand());
    assertEquals(3, end.getArgs().length);
    assertTrue(Arrays.equals(start.getArgs(), end.getArgs()));
  }
View Full Code Here

    assertTrue(Arrays.equals(start.getArgs(), end.getArgs()));
  }

  @Test
  public void testEmptyArgsCommandAvro() {
    Command start = new Command("ls");
    FlumeMasterCommandAvro middle = MasterAdminServerAvro.commandToAvro(start);
    assertEquals("ls", middle.command.toString());
    assertEquals(0, middle.arguments.size());
    Command end = MasterAdminServerAvro.commandFromAvro(middle);
    assertEquals("ls", end.getCommand());
    assertEquals(0, end.getArgs().length);
  }
View Full Code Here

    assertEquals(end.state, start.state);
  }

  @Test
  public void testThriftCommandConversion() {
    Command start = new Command("here", "is", "a", "command");
    FlumeMasterCommandThrift middle = MasterAdminServerThrift.commandToThrift(start);
    assertEquals("here", middle.command.toString());
    assertEquals(3, middle.arguments.size());
    int index = 0;
    for (String s: middle.arguments) {
      switch(index) {
      case 0:
        assertEquals("is", s);
        break;
      case 1:
        assertEquals("a", s);
        break;
      case 2:
        assertEquals("command", s);
        break;
      }
      index++;
    }
    Command end = MasterAdminServerThrift.commandFromThrift(middle);
    assertEquals("here", end.getCommand());
    assertEquals(3, end.getArgs().length);
    assertTrue(Arrays.equals(start.getArgs(), end.getArgs()));
  }
View Full Code Here

    assertTrue(Arrays.equals(start.getArgs(), end.getArgs()));
  }
 
  @Test
  public void testEmptyArgsCommandThrift() {
    Command start = new Command("ls");
    FlumeMasterCommandThrift middle = MasterAdminServerThrift.commandToThrift(start);
    assertEquals("ls", middle.command.toString());
    assertEquals(0, middle.arguments.size());
    Command end = MasterAdminServerThrift.commandFromThrift(middle);
    assertEquals("ls", end.getCommand());
    assertEquals(0, end.getArgs().length);
  }
View Full Code Here

*/
public class TestCommandParser {

  @Test
  public void testParseLine() throws RecognitionException {
    Command c1 = CommandBuilder.parseLine("config");
    assertEquals("config", c1.getCommand());
    assertEquals(0, c1.getArgs().length);

    Command c2 = CommandBuilder.parseLine("config this is a test");
    assertEquals("config", c2.getCommand());
    assertEquals("this", c2.getArgs()[0]);
    assertEquals("is", c2.getArgs()[1]);
    assertEquals("a", c2.getArgs()[2]);
    assertEquals("test", c2.getArgs()[3]);

    Command c3 = CommandBuilder.parseLine("config bla bla-3409h");
    assertEquals("config", c3.getCommand());
    assertEquals("bla", c3.getArgs()[0]);
    assertEquals("bla-3409h", c3.getArgs()[1]);

    // Make sure we parse things that start with numbers or acceptable symbols
    // as well
    Command c4 = CommandBuilder.parseLine("1 -2 :3 .4");
    assertEquals("1", c4.getCommand());
    assertEquals("-2", c4.getArgs()[0]);
    assertEquals(":3", c4.getArgs()[1]);
    assertEquals(".4", c4.getArgs()[2]);
  }
View Full Code Here

    assertEquals(".4", c4.getArgs()[2]);
  }

  @Test
  public void testDQuote() throws RecognitionException {
    Command c = CommandBuilder.parseLine("config bla \"foo\" sdlkjfs");
    assertEquals("config", c.getCommand());
    assertEquals("bla", c.getArgs()[0]);
    assertEquals("foo", c.getArgs()[1]);
    assertEquals("sdlkjfs", c.getArgs()[2]);

    c = CommandBuilder.parseLine("config \"foo blah bkur\"");
    assertEquals("config", c.getCommand());
    assertEquals("foo blah bkur", c.getArgs()[0]);

    c = CommandBuilder.parseLine("\"test\" \"test1\" foobard");
    assertEquals("test", c.getCommand());
    assertEquals("test1", c.getArgs()[0]);
    assertEquals("foobard", c.getArgs()[1]);

  }
View Full Code Here

  }

  @Test
  public void testSQuote() throws RecognitionException {
    Command c = CommandBuilder.parseLine("config bla 'blah'");
    assertEquals("config", c.getCommand());
    assertEquals("bla", c.getArgs()[0]);
    assertEquals("blah", c.getArgs()[1]);

    c = CommandBuilder.parseLine("config '\"foo blah bkur\"'");
    assertEquals("config", c.getCommand());
    assertEquals("\"foo blah bkur\"", c.getArgs()[0]);
  }
View Full Code Here

  /**
   * Test with things commonly found in a flume dataflow spec.
   */
  @Test
  public void testFlumeSpec() throws RecognitionException {
    Command c = CommandBuilder
        .parseLine("config blitzwing 'console' 'console(\"avrojson\")'");
    assertEquals("config", c.getCommand());
    assertEquals("blitzwing", c.getArgs()[0]);
    assertEquals("console", c.getArgs()[1]);
    assertEquals("console(\"avrojson\")", c.getArgs()[2]);

    c = CommandBuilder
        .parseLine("multiconfig 'blitzwing : console | {delay(100) => console(\"avrojson\")};'");
    assertEquals("multiconfig", c.getCommand());
    assertEquals(
        "blitzwing : console | {delay(100) => console(\"avrojson\")};", c
            .getArgs()[0]);
  }
View Full Code Here

TOP

Related Classes of com.cloudera.flume.master.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.