Package org.apache.hive.hcatalog.messaging

Examples of org.apache.hive.hcatalog.messaging.HCatEventMessage


        Assert.assertEquals("topic://" + HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX, msg
            .getJMSDestination().toString());
        CreateDatabaseMessage message =  deserializer.getCreateDatabaseMessage(messageBody);
        Assert.assertEquals("mydb", message.getDB());
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof CreateDatabaseMessage);
        Assert.assertEquals("mydb", message2.getDB());
      } else if (event.equals(HCatConstants.HCAT_CREATE_TABLE_EVENT)) {

        Assert.assertEquals("topic://hcat.mydb", msg.getJMSDestination().toString());
        CreateTableMessage message = deserializer.getCreateTableMessage(messageBody);
        Assert.assertEquals("mytbl", message.getTable());
        Assert.assertEquals("mydb", message.getDB());
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof CreateTableMessage);
        Assert.assertEquals("mydb", message2.getDB());
        Assert.assertEquals("mytbl", ((CreateTableMessage) message2).getTable());
      } else if (event.equals(HCatConstants.HCAT_ADD_PARTITION_EVENT)) {

        Assert.assertEquals("topic://hcat.mydb.mytbl", msg.getJMSDestination()
            .toString());
        AddPartitionMessage message = deserializer.getAddPartitionMessage(messageBody);
        Assert.assertEquals("mytbl", message.getTable());
        Assert.assertEquals("mydb", message.getDB());
        Assert.assertEquals(1, message.getPartitions().size());
        Assert.assertEquals("2011", message.getPartitions().get(0).get("b"));
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof AddPartitionMessage);
        Assert.assertEquals("mydb", message2.getDB());
        Assert.assertEquals("mytbl", ((AddPartitionMessage) message2).getTable());
        Assert.assertEquals(1, ((AddPartitionMessage) message2).getPartitions().size());
        Assert.assertEquals("2011", ((AddPartitionMessage) message2).getPartitions().get(0).get("b"));
      } else if (event.equals(HCatConstants.HCAT_DROP_PARTITION_EVENT)) {

        Assert.assertEquals("topic://hcat.mydb.mytbl", msg.getJMSDestination()
            .toString());
        DropPartitionMessage message = deserializer.getDropPartitionMessage(messageBody);
        Assert.assertEquals("mytbl", message.getTable());
        Assert.assertEquals("mydb", message.getDB());
        Assert.assertEquals(1, message.getPartitions().size());
        Assert.assertEquals("2011", message.getPartitions().get(0).get("b"));
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof DropPartitionMessage);
        Assert.assertEquals("mydb", message2.getDB());
        Assert.assertEquals("mytbl", ((DropPartitionMessage) message2).getTable());
        Assert.assertEquals(1, ((DropPartitionMessage) message2).getPartitions().size());
        Assert.assertEquals("2011", ((DropPartitionMessage) message2).getPartitions().get(0).get("b"));
      } else if (event.equals(HCatConstants.HCAT_DROP_TABLE_EVENT)) {

        Assert.assertEquals("topic://hcat.mydb", msg.getJMSDestination().toString());
        DropTableMessage message = deserializer.getDropTableMessage(messageBody);
        Assert.assertEquals("mytbl", message.getTable());
        Assert.assertEquals("mydb", message.getDB());
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof DropTableMessage);
        Assert.assertEquals("mydb", message2.getDB());
        Assert.assertEquals("mytbl", ((DropTableMessage) message2).getTable());
      } else if (event.equals(HCatConstants.HCAT_DROP_DATABASE_EVENT)) {

        Assert.assertEquals("topic://" + HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX, msg
            .getJMSDestination().toString());
        DropDatabaseMessage message =  deserializer.getDropDatabaseMessage(messageBody);
        Assert.assertEquals("mydb", message.getDB());
        HCatEventMessage message2 = MessagingUtils.getMessage(msg);
        Assert.assertTrue("Unexpected message-type.", message2 instanceof DropDatabaseMessage);
        Assert.assertEquals("mydb", message2.getDB());
      } else if (event.equals(HCatConstants.HCAT_PARTITION_DONE_EVENT)) {
        // TODO: Fill in when PARTITION_DONE_EVENT is supported.
        Assert.assertTrue("Unexpected: HCAT_PARTITION_DONE_EVENT not supported (yet).", false);
      } else {
        Assert.assertTrue("Unexpected event-type: " + event, false);
View Full Code Here


      Message msg = consumer.receive();
      assertTrue("Expected TextMessage", msg instanceof TextMessage);
      assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      HCatEventMessage messageObject = MessagingUtils.getMessage(msg);
      assertEquals("testconndb", messageObject.getDB());
      broker.stop();
      driver.run("drop database testconndb cascade");
      broker.start(true);
      connectClient();
      driver.run("create database testconndb");
      msg = consumer.receive();
      assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      assertEquals("testconndb", messageObject.getDB());
      driver.run("drop database testconndb cascade");
      msg = consumer.receive();
      assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      assertEquals("testconndb", messageObject.getDB());
    } catch (NoSuchObjectException nsoe) {
      nsoe.printStackTrace(System.err);
      assert false;
    } catch (AlreadyExistsException aee) {
      aee.printStackTrace(System.err);
View Full Code Here

     * @param msg : to be processed
     */
    @Override
    public void process(Message msg) {
        try {
            HCatEventMessage hcatMsg = MessagingUtils.getMessage(msg);
            if (hcatMsg.getEventType().equals(HCatEventMessage.EventType.ADD_PARTITION)) {
                // Parse msg components
                AddPartitionMessage partMsg = (AddPartitionMessage) hcatMsg;
                String db = partMsg.getDB();
                String table = partMsg.getTable();
                LOG.info("Partition available event: db [{0}]  table [{1}] partitions [{2}]", db, table,
                        partMsg.getPartitions());
                List<Map<String, String>> partitions = partMsg.getPartitions();
                for (int i = 0; i < partitions.size(); i++) {
                    pdmService.partitionAvailable(this.server, db, table, partitions.get(i));
                }
            }
            else {
                LOG.debug("Ignoring message of event type [{0}] ", hcatMsg.getEventType());
            }
        }
        catch (Exception e) {
            LOG.warn("Error processing JMS message", e);
        }
View Full Code Here

      Message msg = consumer.receive();
      assertTrue("Expected TextMessage", msg instanceof TextMessage);
      assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      HCatEventMessage messageObject = MessagingUtils.getMessage(msg);
      assertEquals("testconndb", messageObject.getDB());
      broker.stop();
      driver.run("drop database testconndb cascade");
      broker.start(true);
      connectClient();
      driver.run("create database testconndb");
      msg = consumer.receive();
      assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      assertEquals("testconndb", messageObject.getDB());
      driver.run("drop database testconndb cascade");
      msg = consumer.receive();
      assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT,
          msg.getStringProperty(HCatConstants.HCAT_EVENT));
      assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
      assertEquals("testconndb", messageObject.getDB());
    } catch (NoSuchObjectException nsoe) {
      nsoe.printStackTrace(System.err);
      assert false;
    } catch (AlreadyExistsException aee) {
      aee.printStackTrace(System.err);
View Full Code Here

TOP

Related Classes of org.apache.hive.hcatalog.messaging.HCatEventMessage

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.