[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-28 Thread Peter Vary (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Peter Vary updated HIVE-19046:
--
   Resolution: Fixed
Fix Version/s: 4.0.0
   Status: Resolved  (was: Patch Available)

Pushed to master.

Thanks [~kuczoram] for the patch!

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Fix For: 4.0.0
>
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch, 
> HIVE-19046.6.patch, HIVE-19046.7.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-25 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.7.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch, 
> HIVE-19046.6.patch, HIVE-19046.7.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-05 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.6.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch, HIVE-19046.6.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-05 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: (was: HIVE-19046.6.patch)

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-05 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.6.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch, HIVE-19046.6.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-06-01 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.5.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch, HIVE-19046.5.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-05-29 Thread Marta Kuczora (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.4.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch, HIVE-19046.4.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List> partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-05-23 Thread Marta Kuczora (JIRA)

 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.3.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch, 
> HIVE-19046.3.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-04-26 Thread Marta Kuczora (JIRA)

 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.2.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch, HIVE-19046.2.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-04-17 Thread Marta Kuczora (JIRA)

 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Attachment: HIVE-19046.1.patch

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (HIVE-19046) Refactor the common parts of the HiveMetastore add_partition_core and add_partitions_pspec_core methods

2018-04-17 Thread Marta Kuczora (JIRA)

 [ 
https://issues.apache.org/jira/browse/HIVE-19046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marta Kuczora updated HIVE-19046:
-
Status: Patch Available  (was: Open)

> Refactor the common parts of the HiveMetastore add_partition_core and 
> add_partitions_pspec_core methods
> ---
>
> Key: HIVE-19046
> URL: https://issues.apache.org/jira/browse/HIVE-19046
> Project: Hive
>  Issue Type: Improvement
>  Components: Metastore
>Reporter: Marta Kuczora
>Assignee: Marta Kuczora
>Priority: Minor
> Attachments: HIVE-19046.1.patch
>
>
> This is a follow-up Jira of the 
> [HIVE-18696|https://issues.apache.org/jira/browse/HIVE-18696] 
> [review|https://reviews.apache.org/r/65716/].
> The biggest part of these methods use the same code. It would make sense to 
> move this code part to a common method.
> This code is almost the same in the two methods:
> {code}
> List partFutures = Lists.newArrayList();
> final Table table = tbl;
> for (final Partition part : parts) {
>   if (!part.getTableName().equals(tblName) || 
> !part.getDbName().equals(dbName)) {
> throw new MetaException("Partition does not belong to target 
> table "
> + dbName + "." + tblName + ": " + part);
>   }
>   boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
>   if (!shouldAdd) {
> existingParts.add(part);
> LOG.info("Not adding partition " + part + " as it already 
> exists");
> continue;
>   }
>   final UserGroupInformation ugi;
>   try {
> ugi = UserGroupInformation.getCurrentUser();
>   } catch (IOException e) {
> throw new RuntimeException(e);
>   }
>   partFutures.add(threadPool.submit(new Callable() {
> @Override
> public Partition call() throws Exception {
>   ugi.doAs(new PrivilegedExceptionAction() {
> @Override
> public Object run() throws Exception {
>   try {
> boolean madeDir = createLocationForAddedPartition(table, 
> part);
> if (addedPartitions.put(new PartValEqWrapper(part), 
> madeDir) != null) {
>   // Technically, for ifNotExists case, we could insert 
> one and discard the other
>   // because the first one now "exists", but it seems 
> better to report the problem
>   // upstream as such a command doesn't make sense.
>   throw new MetaException("Duplicate partitions in the 
> list: " + part);
> }
> initializeAddedPartition(table, part, madeDir);
>   } catch (MetaException e) {
> throw new IOException(e.getMessage(), e);
>   }
>   return null;
> }
>   });
>   return part;
> }
>   }));
> }
> try {
>   for (Future partFuture : partFutures) {
> Partition part = partFuture.get();
> if (part != null) {
>   newParts.add(part);
> }
>   }
> } catch (InterruptedException | ExecutionException e) {
>   // cancel other tasks
>   for (Future partFuture : partFutures) {
> partFuture.cancel(true);
>   }
>   throw new MetaException(e.getMessage());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)