-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: abstract data explorer modules from Influx-related code (#2803
) * refactor: introduce new env variable to determine time series storage * refactor: abstract sanitation * refactor: abstract query management * refactor: abstract counter * refactor: abstract query execution from Influx * refactor: abstract time series store from Influx * refactor: several adaptions * refactor: adapt usages to new APIs * feat: data storage management * refactor: small improvements * style: fix indentation & import order * style: fix import order * style: fix import order * adapt spelling of influx tag * change data explorer storage dispatcher to regular class * adapt to new syntax * refactor: simplify implementation
- Loading branch information
Showing
39 changed files
with
1,020 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...lorer-api/src/main/java/org/apache/streampipes/dataexplorer/api/IDataExplorerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.streampipes.dataexplorer.api; | ||
|
||
import org.apache.streampipes.client.api.IStreamPipesClient; | ||
import org.apache.streampipes.model.datalake.DataLakeMeasure; | ||
|
||
import java.util.List; | ||
|
||
public interface IDataExplorerManager { | ||
|
||
/** | ||
* Provide an instance of {@link IDataLakeMeasurementCounter} for counting the sizes of measurements within a data | ||
* lake. | ||
* | ||
* @param allMeasurements A list of {@link DataLakeMeasure} objects representing all measurements in the data lake. | ||
* @param measurementsToCount A list of measurement names for which the sizes should be counted. | ||
* @return An instance of {@link IDataLakeMeasurementCounter} configured to count the sizes of the specified measurements. | ||
*/ | ||
IDataLakeMeasurementCounter getMeasurementCounter( | ||
List<DataLakeMeasure> allMeasurements, | ||
List<String> measurementsToCount | ||
); | ||
|
||
IDataExplorerQueryManagement getQueryManagement(IDataExplorerSchemaManagement dataExplorerSchemaManagement); | ||
|
||
IDataExplorerSchemaManagement getSchemaManagement(); | ||
|
||
ITimeSeriesStorage getTimeseriesStorage(DataLakeMeasure measure); | ||
|
||
IDataLakeMeasurementSanitizer getMeasurementSanitizer(IStreamPipesClient client, DataLakeMeasure measure); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...pi/src/main/java/org/apache/streampipes/dataexplorer/api/IDataLakeMeasurementCounter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.streampipes.dataexplorer.api; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Interface for counting the number of events per measurement within the StreamPipes data storage. | ||
*/ | ||
public interface IDataLakeMeasurementCounter { | ||
|
||
/** | ||
* Counts the sizes of measurements within the StreamPipes data storage. | ||
* | ||
* @return A map where each key represents a measurement name and its corresponding value represents | ||
* the number of events contained by that measurement. | ||
*/ | ||
Map<String, Integer> countMeasurementSizes(); | ||
} |
48 changes: 48 additions & 0 deletions
48
.../src/main/java/org/apache/streampipes/dataexplorer/api/IDataLakeMeasurementSanitizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.streampipes.dataexplorer.api; | ||
|
||
import org.apache.streampipes.model.datalake.DataLakeMeasure; | ||
|
||
/** | ||
* The IDataLakeMeasurementSanitizer interface defines methods for sanitizing and registering or | ||
* updating data lake measures. | ||
* Implementations of this interface provide functionality to ensure that the measurement complies to | ||
* the requirements of the underlying time series storage, e.g., to not contain any reserved symbols. | ||
*/ | ||
public interface IDataLakeMeasurementSanitizer { | ||
|
||
/** | ||
* Sanitizes and registers a data lake measure. | ||
* This method should perform any necessary data validation and cleanup operations | ||
* before registering the measure in the data lake. | ||
* | ||
* @return The sanitized and registered data lake measure. | ||
*/ | ||
DataLakeMeasure sanitizeAndRegister(); | ||
|
||
/** | ||
* Sanitizes and updates a data lake measure. | ||
* This method should perform any necessary data validation and cleanup operations | ||
* before updating the measure in the data lake. | ||
* | ||
* @return The sanitized and updated data lake measure. | ||
*/ | ||
DataLakeMeasure sanitizeAndUpdate(); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...xplorer-api/src/main/java/org/apache/streampipes/dataexplorer/api/ITimeSeriesStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.streampipes.dataexplorer.api; | ||
|
||
import org.apache.streampipes.commons.exceptions.SpRuntimeException; | ||
import org.apache.streampipes.model.runtime.Event; | ||
|
||
public interface ITimeSeriesStorage { | ||
|
||
void onEvent(Event event) throws SpRuntimeException; | ||
|
||
void close() throws SpRuntimeException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...x/src/main/java/org/apache/streampipes/dataexplorer/influx/DataExplorerManagerInflux.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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.streampipes.dataexplorer.influx; | ||
|
||
import org.apache.streampipes.client.api.IStreamPipesClient; | ||
import org.apache.streampipes.commons.environment.Environments; | ||
import org.apache.streampipes.dataexplorer.DataExplorerSchemaManagement; | ||
import org.apache.streampipes.dataexplorer.api.IDataExplorerQueryManagement; | ||
import org.apache.streampipes.dataexplorer.api.IDataExplorerSchemaManagement; | ||
import org.apache.streampipes.dataexplorer.api.IDataExplorerManager; | ||
import org.apache.streampipes.dataexplorer.api.IDataLakeMeasurementCounter; | ||
import org.apache.streampipes.dataexplorer.api.IDataLakeMeasurementSanitizer; | ||
import org.apache.streampipes.dataexplorer.api.ITimeSeriesStorage; | ||
import org.apache.streampipes.dataexplorer.influx.client.InfluxClientProvider; | ||
import org.apache.streampipes.dataexplorer.influx.sanitize.DataLakeMeasurementSanitizerInflux; | ||
import org.apache.streampipes.model.datalake.DataLakeMeasure; | ||
import org.apache.streampipes.storage.management.StorageDispatcher; | ||
|
||
import java.util.List; | ||
|
||
public enum DataExplorerManagerInflux implements IDataExplorerManager { | ||
|
||
INSTANCE; | ||
|
||
@Override | ||
public IDataLakeMeasurementCounter getMeasurementCounter( | ||
List<DataLakeMeasure> allMeasurements, | ||
List<String> measurementsToCount) { | ||
return new DataLakeMeasurementCounterInflux(allMeasurements, measurementsToCount); | ||
} | ||
|
||
@Override | ||
public IDataExplorerQueryManagement getQueryManagement( | ||
IDataExplorerSchemaManagement dataExplorerSchemaManagement | ||
) { | ||
return new DataExplorerQueryManagementInflux(dataExplorerSchemaManagement); | ||
} | ||
|
||
@Override | ||
public IDataExplorerSchemaManagement getSchemaManagement() { | ||
return new DataExplorerSchemaManagement(StorageDispatcher.INSTANCE | ||
.getNoSqlStore() | ||
.getDataLakeStorage()); | ||
} | ||
|
||
@Override | ||
public ITimeSeriesStorage getTimeseriesStorage(DataLakeMeasure measure) { | ||
return new TimeSeriesStorageInflux(measure, Environments.getEnvironment(), new InfluxClientProvider()); | ||
} | ||
|
||
@Override | ||
public IDataLakeMeasurementSanitizer getMeasurementSanitizer(IStreamPipesClient client, DataLakeMeasure measure) { | ||
return new DataLakeMeasurementSanitizerInflux(client, measure); | ||
} | ||
} |
Oops, something went wrong.