hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1334053 [9/9] - in /hive/trunk: contrib/src/java/org/apache/hadoop/hive/metastore/hooks/ metastore/if/ metastore/src/gen/thrift/gen-cpp/ metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ metastore/src/gen/thrift/g...
Date Fri, 04 May 2012 16:40:27 GMT
Modified: hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py?rev=1334053&r1=1334052&r2=1334053&view=diff
==============================================================================
--- hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py (original)
+++ hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py Fri May  4 16:40:25
2012
@@ -2094,6 +2094,76 @@ class Schema:
   def __ne__(self, other):
     return not (self == other)
 
+class EnvironmentContext:
+  """
+  Attributes:
+   - properties
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.MAP, 'properties', (TType.STRING,None,TType.STRING,None), None, ), # 1
+  )
+
+  def __init__(self, properties=None,):
+    self.properties = properties
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans,
TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.MAP:
+          self.properties = {}
+          (_ktype175, _vtype176, _size174 ) = iprot.readMapBegin() 
+          for _i178 in xrange(_size174):
+            _key179 = iprot.readString();
+            _val180 = iprot.readString();
+            self.properties[_key179] = _val180
+          iprot.readMapEnd()
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec
is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('EnvironmentContext')
+    if self.properties is not None:
+      oprot.writeFieldBegin('properties', TType.MAP, 1)
+      oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.properties))
+      for kiter181,viter182 in self.properties.items():
+        oprot.writeString(kiter181)
+        oprot.writeString(viter182)
+      oprot.writeMapEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    return
+
+
+  def __repr__(self):
+    L = ['%s=%r' % (key, value)
+      for key, value in self.__dict__.iteritems()]
+    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
 class MetaException(Exception):
   """
   Attributes:

Modified: hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb?rev=1334053&r1=1334052&r2=1334053&view=diff
==============================================================================
--- hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb (original)
+++ hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb Fri May  4 16:40:25
2012
@@ -444,6 +444,22 @@ class Schema
   ::Thrift::Struct.generate_accessors self
 end
 
+class EnvironmentContext
+  include ::Thrift::Struct, ::Thrift::Struct_Union
+  PROPERTIES = 1
+
+  FIELDS = {
+    PROPERTIES => {:type => ::Thrift::Types::MAP, :name => 'properties', :key =>
{:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
+  }
+
+  def struct_fields; FIELDS; end
+
+  def validate
+  end
+
+  ::Thrift::Struct.generate_accessors self
+end
+
 class MetaException < ::Thrift::Exception
   include ::Thrift::Struct, ::Thrift::Struct_Union
   def initialize(message=nil)

Modified: hive/trunk/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb?rev=1334053&r1=1334052&r2=1334053&view=diff
==============================================================================
--- hive/trunk/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb (original)
+++ hive/trunk/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb Fri May  4 16:40:25
2012
@@ -233,6 +233,24 @@ module ThriftHiveMetastore
       return
     end
 
+    def create_table_with_environment_context(tbl, environment_context)
+      send_create_table_with_environment_context(tbl, environment_context)
+      recv_create_table_with_environment_context()
+    end
+
+    def send_create_table_with_environment_context(tbl, environment_context)
+      send_message('create_table_with_environment_context', Create_table_with_environment_context_args,
:tbl => tbl, :environment_context => environment_context)
+    end
+
+    def recv_create_table_with_environment_context()
+      result = receive_message(Create_table_with_environment_context_result)
+      raise result.o1 unless result.o1.nil?
+      raise result.o2 unless result.o2.nil?
+      raise result.o3 unless result.o3.nil?
+      raise result.o4 unless result.o4.nil?
+      return
+    end
+
     def drop_table(dbname, name, deleteData)
       send_drop_table(dbname, name, deleteData)
       recv_drop_table()
@@ -350,6 +368,22 @@ module ThriftHiveMetastore
       return
     end
 
+    def alter_table_with_environment_context(dbname, tbl_name, new_tbl, environment_context)
+      send_alter_table_with_environment_context(dbname, tbl_name, new_tbl, environment_context)
+      recv_alter_table_with_environment_context()
+    end
+
+    def send_alter_table_with_environment_context(dbname, tbl_name, new_tbl, environment_context)
+      send_message('alter_table_with_environment_context', Alter_table_with_environment_context_args,
:dbname => dbname, :tbl_name => tbl_name, :new_tbl => new_tbl, :environment_context
=> environment_context)
+    end
+
+    def recv_alter_table_with_environment_context()
+      result = receive_message(Alter_table_with_environment_context_result)
+      raise result.o1 unless result.o1.nil?
+      raise result.o2 unless result.o2.nil?
+      return
+    end
+
     def add_partition(new_part)
       send_add_partition(new_part)
       return recv_add_partition()
@@ -368,6 +402,24 @@ module ThriftHiveMetastore
       raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT,
'add_partition failed: unknown result')
     end
 
+    def add_partition_with_environment_context(new_part, environment_context)
+      send_add_partition_with_environment_context(new_part, environment_context)
+      return recv_add_partition_with_environment_context()
+    end
+
+    def send_add_partition_with_environment_context(new_part, environment_context)
+      send_message('add_partition_with_environment_context', Add_partition_with_environment_context_args,
:new_part => new_part, :environment_context => environment_context)
+    end
+
+    def recv_add_partition_with_environment_context()
+      result = receive_message(Add_partition_with_environment_context_result)
+      return result.success unless result.success.nil?
+      raise result.o1 unless result.o1.nil?
+      raise result.o2 unless result.o2.nil?
+      raise result.o3 unless result.o3.nil?
+      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT,
'add_partition_with_environment_context failed: unknown result')
+    end
+
     def add_partitions(new_parts)
       send_add_partitions(new_parts)
       return recv_add_partitions()
@@ -658,6 +710,22 @@ module ThriftHiveMetastore
       return
     end
 
+    def alter_partition_with_environment_context(db_name, tbl_name, new_part, environment_context)
+      send_alter_partition_with_environment_context(db_name, tbl_name, new_part, environment_context)
+      recv_alter_partition_with_environment_context()
+    end
+
+    def send_alter_partition_with_environment_context(db_name, tbl_name, new_part, environment_context)
+      send_message('alter_partition_with_environment_context', Alter_partition_with_environment_context_args,
:db_name => db_name, :tbl_name => tbl_name, :new_part => new_part, :environment_context
=> environment_context)
+    end
+
+    def recv_alter_partition_with_environment_context()
+      result = receive_message(Alter_partition_with_environment_context_result)
+      raise result.o1 unless result.o1.nil?
+      raise result.o2 unless result.o2.nil?
+      return
+    end
+
     def rename_partition(db_name, tbl_name, part_vals, new_part)
       send_rename_partition(db_name, tbl_name, part_vals, new_part)
       recv_rename_partition()
@@ -1269,6 +1337,23 @@ module ThriftHiveMetastore
       write_result(result, oprot, 'create_table', seqid)
     end
 
+    def process_create_table_with_environment_context(seqid, iprot, oprot)
+      args = read_args(iprot, Create_table_with_environment_context_args)
+      result = Create_table_with_environment_context_result.new()
+      begin
+        @handler.create_table_with_environment_context(args.tbl, args.environment_context)
+      rescue AlreadyExistsException => o1
+        result.o1 = o1
+      rescue InvalidObjectException => o2
+        result.o2 = o2
+      rescue MetaException => o3
+        result.o3 = o3
+      rescue NoSuchObjectException => o4
+        result.o4 = o4
+      end
+      write_result(result, oprot, 'create_table_with_environment_context', seqid)
+    end
+
     def process_drop_table(seqid, iprot, oprot)
       args = read_args(iprot, Drop_table_args)
       result = Drop_table_result.new()
@@ -1360,6 +1445,19 @@ module ThriftHiveMetastore
       write_result(result, oprot, 'alter_table', seqid)
     end
 
+    def process_alter_table_with_environment_context(seqid, iprot, oprot)
+      args = read_args(iprot, Alter_table_with_environment_context_args)
+      result = Alter_table_with_environment_context_result.new()
+      begin
+        @handler.alter_table_with_environment_context(args.dbname, args.tbl_name, args.new_tbl,
args.environment_context)
+      rescue InvalidOperationException => o1
+        result.o1 = o1
+      rescue MetaException => o2
+        result.o2 = o2
+      end
+      write_result(result, oprot, 'alter_table_with_environment_context', seqid)
+    end
+
     def process_add_partition(seqid, iprot, oprot)
       args = read_args(iprot, Add_partition_args)
       result = Add_partition_result.new()
@@ -1375,6 +1473,21 @@ module ThriftHiveMetastore
       write_result(result, oprot, 'add_partition', seqid)
     end
 
+    def process_add_partition_with_environment_context(seqid, iprot, oprot)
+      args = read_args(iprot, Add_partition_with_environment_context_args)
+      result = Add_partition_with_environment_context_result.new()
+      begin
+        result.success = @handler.add_partition_with_environment_context(args.new_part, args.environment_context)
+      rescue InvalidObjectException => o1
+        result.o1 = o1
+      rescue AlreadyExistsException => o2
+        result.o2 = o2
+      rescue MetaException => o3
+        result.o3 = o3
+      end
+      write_result(result, oprot, 'add_partition_with_environment_context', seqid)
+    end
+
     def process_add_partitions(seqid, iprot, oprot)
       args = read_args(iprot, Add_partitions_args)
       result = Add_partitions_result.new()
@@ -1600,6 +1713,19 @@ module ThriftHiveMetastore
       write_result(result, oprot, 'alter_partition', seqid)
     end
 
+    def process_alter_partition_with_environment_context(seqid, iprot, oprot)
+      args = read_args(iprot, Alter_partition_with_environment_context_args)
+      result = Alter_partition_with_environment_context_result.new()
+      begin
+        @handler.alter_partition_with_environment_context(args.db_name, args.tbl_name, args.new_part,
args.environment_context)
+      rescue InvalidOperationException => o1
+        result.o1 = o1
+      rescue MetaException => o2
+        result.o2 = o2
+      end
+      write_result(result, oprot, 'alter_partition_with_environment_context', seqid)
+    end
+
     def process_rename_partition(seqid, iprot, oprot)
       args = read_args(iprot, Rename_partition_args)
       result = Rename_partition_result.new()
@@ -2401,6 +2527,46 @@ module ThriftHiveMetastore
     ::Thrift::Struct.generate_accessors self
   end
 
+  class Create_table_with_environment_context_args
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    TBL = 1
+    ENVIRONMENT_CONTEXT = 2
+
+    FIELDS = {
+      TBL => {:type => ::Thrift::Types::STRUCT, :name => 'tbl', :class => Table},
+      ENVIRONMENT_CONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environment_context',
:class => EnvironmentContext}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
+  class Create_table_with_environment_context_result
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    O1 = 1
+    O2 = 2
+    O3 = 3
+    O4 = 4
+
+    FIELDS = {
+      O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => AlreadyExistsException},
+      O2 => {:type => ::Thrift::Types::STRUCT, :name => 'o2', :class => InvalidObjectException},
+      O3 => {:type => ::Thrift::Types::STRUCT, :name => 'o3', :class => MetaException},
+      O4 => {:type => ::Thrift::Types::STRUCT, :name => 'o4', :class => NoSuchObjectException}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
   class Drop_table_args
     include ::Thrift::Struct, ::Thrift::Struct_Union
     DBNAME = 1
@@ -2667,6 +2833,46 @@ module ThriftHiveMetastore
     ::Thrift::Struct.generate_accessors self
   end
 
+  class Alter_table_with_environment_context_args
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    DBNAME = 1
+    TBL_NAME = 2
+    NEW_TBL = 3
+    ENVIRONMENT_CONTEXT = 4
+
+    FIELDS = {
+      DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
+      TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'tbl_name'},
+      NEW_TBL => {:type => ::Thrift::Types::STRUCT, :name => 'new_tbl', :class =>
Table},
+      ENVIRONMENT_CONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environment_context',
:class => EnvironmentContext}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
+  class Alter_table_with_environment_context_result
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    O1 = 1
+    O2 = 2
+
+    FIELDS = {
+      O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => InvalidOperationException},
+      O2 => {:type => ::Thrift::Types::STRUCT, :name => 'o2', :class => MetaException}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
   class Add_partition_args
     include ::Thrift::Struct, ::Thrift::Struct_Union
     NEW_PART = 1
@@ -2705,6 +2911,46 @@ module ThriftHiveMetastore
     ::Thrift::Struct.generate_accessors self
   end
 
+  class Add_partition_with_environment_context_args
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    NEW_PART = 1
+    ENVIRONMENT_CONTEXT = 2
+
+    FIELDS = {
+      NEW_PART => {:type => ::Thrift::Types::STRUCT, :name => 'new_part', :class
=> Partition},
+      ENVIRONMENT_CONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environment_context',
:class => EnvironmentContext}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
+  class Add_partition_with_environment_context_result
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    SUCCESS = 0
+    O1 = 1
+    O2 = 2
+    O3 = 3
+
+    FIELDS = {
+      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class =>
Partition},
+      O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => InvalidObjectException},
+      O2 => {:type => ::Thrift::Types::STRUCT, :name => 'o2', :class => AlreadyExistsException},
+      O3 => {:type => ::Thrift::Types::STRUCT, :name => 'o3', :class => MetaException}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
   class Add_partitions_args
     include ::Thrift::Struct, ::Thrift::Struct_Union
     NEW_PARTS = 1
@@ -3407,6 +3653,46 @@ module ThriftHiveMetastore
     ::Thrift::Struct.generate_accessors self
   end
 
+  class Alter_partition_with_environment_context_args
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    DB_NAME = 1
+    TBL_NAME = 2
+    NEW_PART = 3
+    ENVIRONMENT_CONTEXT = 4
+
+    FIELDS = {
+      DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'db_name'},
+      TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'tbl_name'},
+      NEW_PART => {:type => ::Thrift::Types::STRUCT, :name => 'new_part', :class
=> Partition},
+      ENVIRONMENT_CONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environment_context',
:class => EnvironmentContext}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
+  class Alter_partition_with_environment_context_result
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    O1 = 1
+    O2 = 2
+
+    FIELDS = {
+      O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => InvalidOperationException},
+      O2 => {:type => ::Thrift::Types::STRUCT, :name => 'o2', :class => MetaException}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
   class Rename_partition_args
     include ::Thrift::Struct, ::Thrift::Struct_Union
     DB_NAME = 1

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=1334053&r1=1334052&r2=1334053&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Fri
May  4 16:40:25 2012
@@ -57,6 +57,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.ConfigValSecurityException;
 import org.apache.hadoop.hive.metastore.api.Constants;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
 import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
@@ -778,8 +779,10 @@ public class HiveMetaStore extends Thrif
       throw new MetaException("Not yet implemented");
     }
 
-    private void create_table_core(final RawStore ms, final Table tbl)
-        throws AlreadyExistsException, MetaException, InvalidObjectException, NoSuchObjectException
{
+    private void create_table_core(final RawStore ms, final Table tbl,
+        final EnvironmentContext envContext)
+        throws AlreadyExistsException, MetaException,
+               InvalidObjectException, NoSuchObjectException {
 
       if (!MetaStoreUtils.validateName(tbl.getTableName())
           || !MetaStoreUtils.validateColNames(tbl.getSd().getCols())
@@ -855,18 +858,35 @@ public class HiveMetaStore extends Thrif
           }
         }
         for (MetaStoreEventListener listener : listeners) {
-          listener.onCreateTable(new CreateTableEvent(tbl, success, this));
+          CreateTableEvent createTableEvent =
+              new CreateTableEvent(tbl, success, this);
+          createTableEvent.setEnvironmentContext(envContext);
+          listener.onCreateTable(createTableEvent);
         }
       }
     }
 
+    @Override
     public void create_table(final Table tbl) throws AlreadyExistsException,
         MetaException, InvalidObjectException {
+      create_table(tbl, null);
+    }
+
+    @Override
+    public void create_table_with_environment_context(final Table table,
+        final EnvironmentContext envContext)
+        throws AlreadyExistsException, MetaException, InvalidObjectException {
+      create_table(table, envContext);
+    }
+
+    private void create_table(final Table tbl,
+        final EnvironmentContext envContext) throws AlreadyExistsException,
+        MetaException, InvalidObjectException {
       startFunction("create_table", ": db=" + tbl.getDbName() + " tbl="
           + tbl.getTableName());
       boolean success = false;
       try {
-        create_table_core(getMS(), tbl);
+        create_table_core(getMS(), tbl, envContext);
         success = true;
       } catch (NoSuchObjectException e) {
         throw new InvalidObjectException(e.getMessage());
@@ -1163,7 +1183,8 @@ public class HiveMetaStore extends Thrif
       try {
         ms.openTransaction();
         for (Partition part : parts) {
-          Entry<Partition, Boolean> e = add_partition_core_notxn(ms, part);
+          // No environment context is passed.
+          Entry<Partition, Boolean> e = add_partition_core_notxn(ms, part, null);
           addedPartitions.put(e.getKey(), e.getValue());
         }
         success = true;
@@ -1205,13 +1226,15 @@ public class HiveMetaStore extends Thrif
      *
      * @param ms
      * @param part
+     * @param envContext parameters passed by the client
      * @return
      * @throws InvalidObjectException
      * @throws AlreadyExistsException
      * @throws MetaException
      */
     private Entry<Partition, Boolean> add_partition_core_notxn(
-        final RawStore ms, final Partition part)
+        final RawStore ms, final Partition part,
+        final EnvironmentContext envContext)
         throws InvalidObjectException, AlreadyExistsException, MetaException {
       boolean success = false, madeDir = false;
       Path partLocation = null;
@@ -1314,7 +1337,10 @@ public class HiveMetaStore extends Thrif
           }
         }
         for (MetaStoreEventListener listener : listeners) {
-          listener.onAddPartition(new AddPartitionEvent(part, success, this));
+          AddPartitionEvent addPartitionEvent =
+              new AddPartitionEvent(part, success, this);
+          addPartitionEvent.setEnvironmentContext(envContext);
+          listener.onAddPartition(addPartitionEvent);
         }
       }
       Map<Partition, Boolean> returnVal = new HashMap<Partition, Boolean>();
@@ -1322,13 +1348,14 @@ public class HiveMetaStore extends Thrif
       return returnVal.entrySet().iterator().next();
     }
 
-    private Partition add_partition_core(final RawStore ms, final Partition part)
+    private Partition add_partition_core(final RawStore ms,
+        final Partition part, final EnvironmentContext envContext)
         throws InvalidObjectException, AlreadyExistsException, MetaException {
       boolean success = false;
       Partition retPtn = null;
       try {
         ms.openTransaction();
-        retPtn = add_partition_core_notxn(ms, part).getKey();
+        retPtn = add_partition_core_notxn(ms, part, envContext).getKey();
         // we proceed only if we'd actually succeeded anyway, otherwise,
         // we'd have thrown an exception
         success = ms.commitTransaction();
@@ -1340,18 +1367,32 @@ public class HiveMetaStore extends Thrif
       return retPtn;
     }
 
+    @Override
     public Partition add_partition(final Partition part)
         throws InvalidObjectException, AlreadyExistsException, MetaException {
-      startTableFunction("add_partition", part.getDbName(), part.getTableName());
+      return add_partition(part, null);
+    }
+
+    @Override
+    public Partition add_partition_with_environment_context(
+        final Partition part, EnvironmentContext envContext)
+        throws InvalidObjectException, AlreadyExistsException,
+        MetaException {
+      return add_partition(part, envContext);
+    }
 
+    private Partition add_partition(final Partition part,
+        final EnvironmentContext envContext) throws InvalidObjectException,
+        AlreadyExistsException, MetaException {
+      startTableFunction("add_partition",
+          part.getDbName(), part.getTableName());
       Partition ret = null;
       try {
-        ret = add_partition_core(getMS(), part);
+        ret = add_partition_core(getMS(), part, envContext);
       } finally {
         endFunction("add_partition", ret != null);
       }
       return ret;
-
     }
 
     private boolean drop_partition_common(RawStore ms, String db_name, String tbl_name,
@@ -1526,6 +1567,7 @@ public class HiveMetaStore extends Thrif
       return ret;
     }
 
+    @Override
     public void alter_partition(final String db_name, final String tbl_name,
         final Partition new_part)
         throws InvalidOperationException, MetaException,
@@ -1533,8 +1575,26 @@ public class HiveMetaStore extends Thrif
       rename_partition(db_name, tbl_name, null, new_part);
     }
 
+    @Override
+    public void alter_partition_with_environment_context(final String dbName,
+        final String tableName, final Partition newPartition,
+        final EnvironmentContext envContext)
+        throws InvalidOperationException, MetaException, TException {
+        rename_partition(dbName, tableName, null,
+            newPartition, envContext);
+    }
+
+    @Override
     public void rename_partition(final String db_name, final String tbl_name,
         final List<String> part_vals, final Partition new_part)
+        throws InvalidOperationException, MetaException, TException {
+      // Call rename_partition without an environment context.
+      rename_partition(db_name, tbl_name, part_vals, new_part, null);
+    }
+
+    private void rename_partition(final String db_name, final String tbl_name,
+        final List<String> part_vals, final Partition new_part,
+        final EnvironmentContext envContext)
         throws InvalidOperationException, MetaException,
         TException {
       startTableFunction("alter_partition", db_name, tbl_name);
@@ -1560,7 +1620,10 @@ public class HiveMetaStore extends Thrif
         oldPart = alterHandler.alterPartition(getMS(), wh, db_name, tbl_name, part_vals,
new_part);
 
         for (MetaStoreEventListener listener : listeners) {
-          listener.onAlterPartition(new AlterPartitionEvent(oldPart, new_part, true, this));
+          AlterPartitionEvent alterPartitionEvent =
+              new AlterPartitionEvent(oldPart, new_part, true, this);
+          alterPartitionEvent.setEnvironmentContext(envContext);
+          listener.onAlterPartition(alterPartitionEvent);
         }
       } catch (InvalidObjectException e) {
         throw new InvalidOperationException(e.getMessage());
@@ -1604,7 +1667,24 @@ public class HiveMetaStore extends Thrif
       return "3.0";
     }
 
-    public void alter_table(final String dbname, final String name, final Table newTable)
+    @Override
+    public void alter_table(final String dbname, final String name,
+        final Table newTable)
+        throws InvalidOperationException, MetaException {
+      // Do not set an environment context.
+      alter_table(dbname, name, newTable, null);
+    }
+
+    @Override
+    public void alter_table_with_environment_context(final String dbname,
+        final String name, final Table newTable,
+        final EnvironmentContext envContext)
+        throws InvalidOperationException, MetaException {
+      alter_table(dbname, name, newTable, envContext);
+    }
+
+    private void alter_table(final String dbname, final String name,
+        final Table newTable, final EnvironmentContext envContext)
         throws InvalidOperationException, MetaException {
       startFunction("alter_table", ": db=" + dbname + " tbl=" + name
           + " newtbl=" + newTable.getTableName());
@@ -1630,7 +1710,10 @@ public class HiveMetaStore extends Thrif
         success = true;
 
         for (MetaStoreEventListener listener : listeners) {
-          listener.onAlterTable(new AlterTableEvent(oldt, newTable, success, this));
+          AlterTableEvent alterTableEvent =
+              new AlterTableEvent(oldt, newTable, success, this);
+          alterTableEvent.setEnvironmentContext(envContext);
+          listener.onAlterTable(alterTableEvent);
         }
       } catch (NoSuchObjectException e) {
         // thrown when the table to be altered does not exist

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java?rev=1334053&r1=1334052&r2=1334053&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java
(original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/events/ListenerEvent.java
Fri May  4 16:40:25 2012
@@ -20,6 +20,8 @@ package org.apache.hadoop.hive.metastore
 
 import org.apache.hadoop.hive.metastore.HiveMetaStore.HMSHandler;
 
+import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
+
 /**
  * Base class for all the events which are defined for metastore.
  */
@@ -32,6 +34,9 @@ public abstract class ListenerEvent {
   private final boolean status;
   private final HMSHandler handler;
 
+  // Properties passed by the client, to be used in execution hooks.
+  private EnvironmentContext environmentContext = null;
+
   public ListenerEvent(boolean status, HMSHandler handler) {
     super();
     this.status = status;
@@ -52,4 +57,15 @@ public abstract class ListenerEvent {
     return status;
   }
 
+  public void setEnvironmentContext(EnvironmentContext environmentContext) {
+    this.environmentContext = environmentContext;
+  }
+
+  /**
+   * @return environment properties of the event
+   */
+  public EnvironmentContext getEnvironmentContext() {
+    return environmentContext;
+  }
+
 }



Mime
View raw message