You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2023/02/17 07:00:37 UTC
[iotdb] 01/16: define basic class
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/modelManager
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 439535960119fd400bc0bd42d48dfe515c69fc11
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Thu Jan 5 11:30:04 2023 +0800
define basic class
---
.../iotdb/confignode/manager/ConfigManager.java | 9 +++-
.../iotdb/confignode/manager/ModelManager.java | 38 ++++++++++++++
.../iotdb/confignode/persistence/ModelInfo.java | 61 ++++++++++++++++++++++
.../persistence/executor/ConfigPlanExecutor.java | 9 +++-
.../commons/model/AbstractModelInformation.java | 22 ++++++++
.../commons/model/ForecastModelInformation.java | 22 ++++++++
.../org/apache/iotdb/commons/model/ModelTable.java | 22 ++++++++
7 files changed, 181 insertions(+), 2 deletions(-)
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index a5ea78ed40..888a929285 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -86,6 +86,7 @@ import org.apache.iotdb.confignode.manager.node.ClusterNodeStartUtils;
import org.apache.iotdb.confignode.manager.node.NodeManager;
import org.apache.iotdb.confignode.manager.partition.PartitionManager;
import org.apache.iotdb.confignode.persistence.AuthorInfo;
+import org.apache.iotdb.confignode.persistence.ModelInfo;
import org.apache.iotdb.confignode.persistence.ProcedureInfo;
import org.apache.iotdb.confignode.persistence.TriggerInfo;
import org.apache.iotdb.confignode.persistence.UDFInfo;
@@ -213,6 +214,9 @@ public class ConfigManager implements IManager {
/** CQ */
private final CQManager cqManager;
+ /** ML Model */
+ private final ModelManager modelManager;
+
private final ConfigNodeRegionStateMachine stateMachine;
private final RetryFailedTasksThread retryFailedTasksThread;
@@ -228,6 +232,7 @@ public class ConfigManager implements IManager {
TriggerInfo triggerInfo = new TriggerInfo();
ClusterSyncInfo syncInfo = new ClusterSyncInfo();
CQInfo cqInfo = new CQInfo();
+ ModelInfo modelInfo = new ModelInfo();
// Build state machine and executor
ConfigPlanExecutor executor =
@@ -240,7 +245,8 @@ public class ConfigManager implements IManager {
udfInfo,
triggerInfo,
syncInfo,
- cqInfo);
+ cqInfo,
+ modelInfo);
this.stateMachine = new ConfigNodeRegionStateMachine(this, executor);
// Build the manager module
@@ -254,6 +260,7 @@ public class ConfigManager implements IManager {
this.syncManager = new SyncManager(this, syncInfo);
this.cqManager = new CQManager(this);
this.loadManager = new LoadManager(this);
+ this.modelManager = new ModelManager(this, modelInfo);
this.retryFailedTasksThread = new RetryFailedTasksThread(this);
}
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ModelManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ModelManager.java
new file mode 100644
index 0000000000..f24081bc73
--- /dev/null
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ModelManager.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.manager;
+
+import org.apache.iotdb.confignode.persistence.ModelInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ModelManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModelManager.class);
+
+ private final ConfigManager configManager;
+ private final ModelInfo modelInfo;
+
+ public ModelManager(ConfigManager configManager, ModelInfo modelInfo) {
+ this.configManager = configManager;
+ this.modelInfo = modelInfo;
+ }
+}
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/ModelInfo.java b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/ModelInfo.java
new file mode 100644
index 0000000000..9a13858efe
--- /dev/null
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/ModelInfo.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.persistence;
+
+import org.apache.iotdb.commons.model.AbstractModelInformation;
+import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
+
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.concurrent.ThreadSafe;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+@ThreadSafe
+public class ModelInfo implements SnapshotProcessor {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModelInfo.class);
+
+ private static final String SNAPSHOT_FILENAME = "model_info.snapshot";
+
+ private final Map<String, AbstractModelInformation> modelInfoMap;
+
+ private final ReadWriteLock lock;
+
+ public ModelInfo() {
+ this.modelInfoMap = new HashMap<>();
+ this.lock = new ReentrantReadWriteLock();
+ }
+
+ @Override
+ public boolean processTakeSnapshot(File snapshotDir) throws TException, IOException {
+ return false;
+ }
+
+ @Override
+ public void processLoadSnapshot(File snapshotDir) throws TException, IOException {}
+}
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
index 47a44c754d..b4b7d2c148 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
@@ -92,6 +92,7 @@ import org.apache.iotdb.confignode.consensus.request.write.trigger.UpdateTrigger
import org.apache.iotdb.confignode.consensus.response.SchemaNodeManagementResp;
import org.apache.iotdb.confignode.exception.physical.UnknownPhysicalPlanTypeException;
import org.apache.iotdb.confignode.persistence.AuthorInfo;
+import org.apache.iotdb.confignode.persistence.ModelInfo;
import org.apache.iotdb.confignode.persistence.ProcedureInfo;
import org.apache.iotdb.confignode.persistence.TriggerInfo;
import org.apache.iotdb.confignode.persistence.UDFInfo;
@@ -146,6 +147,8 @@ public class ConfigPlanExecutor {
private final CQInfo cqInfo;
+ private final ModelInfo modelInfo;
+
public ConfigPlanExecutor(
NodeInfo nodeInfo,
ClusterSchemaInfo clusterSchemaInfo,
@@ -155,7 +158,8 @@ public class ConfigPlanExecutor {
UDFInfo udfInfo,
TriggerInfo triggerInfo,
ClusterSyncInfo syncInfo,
- CQInfo cqInfo) {
+ CQInfo cqInfo,
+ ModelInfo modelInfo) {
this.snapshotProcessorList = new ArrayList<>();
@@ -183,6 +187,9 @@ public class ConfigPlanExecutor {
this.cqInfo = cqInfo;
this.snapshotProcessorList.add(cqInfo);
+ this.modelInfo = modelInfo;
+ this.snapshotProcessorList.add(modelInfo);
+
this.procedureInfo = procedureInfo;
}
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/model/AbstractModelInformation.java b/node-commons/src/main/java/org/apache/iotdb/commons/model/AbstractModelInformation.java
new file mode 100644
index 0000000000..8436eab044
--- /dev/null
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/model/AbstractModelInformation.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.model;
+
+public class AbstractModelInformation {}
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/model/ForecastModelInformation.java b/node-commons/src/main/java/org/apache/iotdb/commons/model/ForecastModelInformation.java
new file mode 100644
index 0000000000..63f20a4834
--- /dev/null
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/model/ForecastModelInformation.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.model;
+
+public class ForecastModelInformation extends AbstractModelInformation {}
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/model/ModelTable.java b/node-commons/src/main/java/org/apache/iotdb/commons/model/ModelTable.java
new file mode 100644
index 0000000000..14e4903043
--- /dev/null
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/model/ModelTable.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.model;
+
+public class ModelTable {}