|
85 | 85 | import org.apache.iotdb.commons.udf.service.UDFExecutableManager; |
86 | 86 | import org.apache.iotdb.commons.utils.CommonDateTimeUtils; |
87 | 87 | import org.apache.iotdb.commons.utils.PathUtils; |
| 88 | +import org.apache.iotdb.commons.utils.SerializeUtils; |
88 | 89 | import org.apache.iotdb.commons.utils.TimePartitionUtils; |
89 | 90 | import org.apache.iotdb.confignode.rpc.thrift.TAINodeRemoveReq; |
| 91 | +import org.apache.iotdb.confignode.rpc.thrift.TAlterEncodingCompressorReq; |
90 | 92 | import org.apache.iotdb.confignode.rpc.thrift.TAlterLogicalViewReq; |
91 | 93 | import org.apache.iotdb.confignode.rpc.thrift.TAlterOrDropTableReq; |
92 | 94 | import org.apache.iotdb.confignode.rpc.thrift.TAlterPipeReq; |
|
246 | 248 | import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster; |
247 | 249 | import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDB; |
248 | 250 | import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Use; |
| 251 | +import org.apache.iotdb.db.queryengine.plan.statement.metadata.AlterEncodingCompressorStatement; |
249 | 252 | import org.apache.iotdb.db.queryengine.plan.statement.metadata.CountDatabaseStatement; |
250 | 253 | import org.apache.iotdb.db.queryengine.plan.statement.metadata.CountTimeSlotListStatement; |
251 | 254 | import org.apache.iotdb.db.queryengine.plan.statement.metadata.CreateContinuousQueryStatement; |
@@ -2779,6 +2782,65 @@ public SettableFuture<ConfigTaskResult> showTopics( |
2779 | 2782 | return future; |
2780 | 2783 | } |
2781 | 2784 |
|
| 2785 | + @Override |
| 2786 | + public SettableFuture<ConfigTaskResult> alterEncodingCompressor( |
| 2787 | + final String queryId, |
| 2788 | + final AlterEncodingCompressorStatement alterEncodingCompressorStatement) { |
| 2789 | + final SettableFuture<ConfigTaskResult> future = SettableFuture.create(); |
| 2790 | + // Will only occur if no permission |
| 2791 | + if (alterEncodingCompressorStatement.getPatternTree().isEmpty()) { |
| 2792 | + future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS)); |
| 2793 | + return future; |
| 2794 | + } |
| 2795 | + final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| 2796 | + final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); |
| 2797 | + try { |
| 2798 | + alterEncodingCompressorStatement.getPatternTree().serialize(dataOutputStream); |
| 2799 | + } catch (final IOException ignored) { |
| 2800 | + // memory operation, won't happen |
| 2801 | + } |
| 2802 | + final TAlterEncodingCompressorReq req = |
| 2803 | + new TAlterEncodingCompressorReq( |
| 2804 | + queryId, |
| 2805 | + ByteBuffer.wrap(byteArrayOutputStream.toByteArray()), |
| 2806 | + SerializeUtils.serializeNullable(alterEncodingCompressorStatement.getEncoding()), |
| 2807 | + SerializeUtils.serializeNullable(alterEncodingCompressorStatement.getCompressor()), |
| 2808 | + alterEncodingCompressorStatement.ifExists(), |
| 2809 | + alterEncodingCompressorStatement.isWithAudit()); |
| 2810 | + try (final ConfigNodeClient client = |
| 2811 | + CLUSTER_DELETION_CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { |
| 2812 | + TSStatus tsStatus; |
| 2813 | + do { |
| 2814 | + try { |
| 2815 | + tsStatus = client.alterEncodingCompressor(req); |
| 2816 | + } catch (final TTransportException e) { |
| 2817 | + if (e.getType() == TTransportException.TIMED_OUT |
| 2818 | + || e.getCause() instanceof SocketTimeoutException) { |
| 2819 | + // time out mainly caused by slow execution, wait until |
| 2820 | + tsStatus = RpcUtils.getStatus(TSStatusCode.OVERLAP_WITH_EXISTING_TASK); |
| 2821 | + } else { |
| 2822 | + throw e; |
| 2823 | + } |
| 2824 | + } |
| 2825 | + // keep waiting until task ends |
| 2826 | + } while (TSStatusCode.OVERLAP_WITH_EXISTING_TASK.getStatusCode() == tsStatus.getCode()); |
| 2827 | + |
| 2828 | + if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) { |
| 2829 | + if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { |
| 2830 | + future.setException( |
| 2831 | + new BatchProcessException(tsStatus.subStatus.toArray(new TSStatus[0]))); |
| 2832 | + } else { |
| 2833 | + future.setException(new IoTDBException(tsStatus)); |
| 2834 | + } |
| 2835 | + } else { |
| 2836 | + future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS)); |
| 2837 | + } |
| 2838 | + } catch (final ClientManagerException | TException e) { |
| 2839 | + future.setException(e); |
| 2840 | + } |
| 2841 | + return future; |
| 2842 | + } |
| 2843 | + |
2782 | 2844 | @Override |
2783 | 2845 | public SettableFuture<ConfigTaskResult> deleteTimeSeries( |
2784 | 2846 | final String queryId, final DeleteTimeSeriesStatement deleteTimeSeriesStatement) { |
|
0 commit comments