Xikui Wang has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1664
Change subject: Add test cases for alive feed check when connect/disconnect ...................................................................... Add test cases for alive feed check when connect/disconnect `connect feed' and `disconnect feed` are not allowed when feed is alive. Add two test case to check both exceptions. Change-Id: Icbcc19da2a9f42bee21b52932ba4f19a0f01aeec --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.0.ddl.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.1.update.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.2.sleep.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.3.update.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.0.ddl.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.1.update.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.2.sleep.aql A asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.3.update.aql M asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java M asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties 12 files changed, 228 insertions(+), 2 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/64/1664/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java index 88d07e4..cb59f5c 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java @@ -60,6 +60,7 @@ import org.apache.asterix.common.context.IStorageComponentProvider; import org.apache.asterix.common.exceptions.ACIDException; import org.apache.asterix.common.exceptions.CompilationException; +import org.apache.asterix.common.exceptions.ErrorCode; import org.apache.asterix.common.functions.FunctionSignature; import org.apache.asterix.common.metadata.IDataset; import org.apache.asterix.common.utils.JobUtils; @@ -2104,6 +2105,11 @@ String policyName = cfs.getPolicy(); MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); + // Check whether feed is alive + if (ActiveJobNotificationHandler.INSTANCE + .getActiveEntityListener(new EntityId(Feed.EXTENSION_NAME, dataverseName, feedName)) != null) { + throw new CompilationException(ErrorCode.FEED_CHANGE_FEED_CONNECTIVITY_ON_ALIVE_FEED, feedName); + } // Transaction handling MetadataLockManager.INSTANCE.connectFeedBegin(metadataProvider.getLocks(), dataverseName, dataverseName + "." + datasetName, dataverseName + "." + feedName); @@ -2139,6 +2145,11 @@ String feedName = cfs.getFeedName().getValue(); MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); + // Check whether feed is alive + if (ActiveJobNotificationHandler.INSTANCE + .getActiveEntityListener(new EntityId(Feed.EXTENSION_NAME, dataverseName, feedName)) != null) { + throw new CompilationException(ErrorCode.FEED_CHANGE_FEED_CONNECTIVITY_ON_ALIVE_FEED, feedName); + } MetadataLockManager.INSTANCE.disconnectFeedBegin(metadataProvider.getLocks(), dataverseName, dataverseName + "." + datasetName, dataverseName + "." + cfs.getFeedName()); try { diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.0.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.0.ddl.aql new file mode 100644 index 0000000..47bee4d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.0.ddl.aql @@ -0,0 +1,40 @@ +/* + * 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. + */ + +drop dataverse new_experiments if exists; +create dataverse new_experiments; +use dataverse new_experiments; + +create type TweetMessageType as closed { + tweetid: string, + tweetid-copy:string +} + +create dataset Tweets1(TweetMessageType) primary key tweetid; +create dataset Tweets2(TweetMessageType) primary key tweetid; + +create feed TweetFeed using socket_adapter +( + ("sockets"="127.0.0.1:10001"), + ("address-type"="IP"), + ("type-name"="TweetMessageType"), + ("format"="adm") +); + +connect feed TweetFeed to dataset Tweets1; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.1.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.1.update.aql new file mode 100644 index 0000000..4f3cb19 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.1.update.aql @@ -0,0 +1,21 @@ +/* + * 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. + */ + +use dataverse new_experiments; +start feed TweetFeed; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.2.sleep.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.2.sleep.aql new file mode 100644 index 0000000..5af9639 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.2.sleep.aql @@ -0,0 +1,19 @@ +/* + * 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. + */ +1000 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.3.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.3.update.aql new file mode 100644 index 0000000..4b7aaa4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.3.update.aql @@ -0,0 +1,21 @@ +/* + * 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.1 + */ + +use dataverse new_experiments; +connect feed TweetFeed to dataset Tweets2; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.0.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.0.ddl.aql new file mode 100644 index 0000000..00fb12d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.0.ddl.aql @@ -0,0 +1,41 @@ +/* + * 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. + */ + +drop dataverse new_experiments if exists; +create dataverse new_experiments; +use dataverse new_experiments; + +create type TweetMessageType as closed { + tweetid: string, + tweetid-copy:string +} + +create dataset Tweets1(TweetMessageType) primary key tweetid; +create dataset Tweets2(TweetMessageType) primary key tweetid; + +create feed TweetFeed using socket_adapter +( + ("sockets"="127.0.0.1:10001"), + ("address-type"="IP"), + ("type-name"="TweetMessageType"), + ("format"="adm") +); + +connect feed TweetFeed to dataset Tweets1; +connect feed TweetFeed to dataset Tweets2; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.1.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.1.update.aql new file mode 100644 index 0000000..4f3cb19 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.1.update.aql @@ -0,0 +1,21 @@ +/* + * 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. + */ + +use dataverse new_experiments; +start feed TweetFeed; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.2.sleep.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.2.sleep.aql new file mode 100644 index 0000000..5af9639 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.2.sleep.aql @@ -0,0 +1,19 @@ +/* + * 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. + */ +1000 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.3.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.3.update.aql new file mode 100644 index 0000000..0095d89 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.3.update.aql @@ -0,0 +1,21 @@ +/* + * 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.1 + */ + +use dataverse new_experiments; +disconnect feed TweetFeed from dataset Tweets1; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml index 122a4c6..7a486b7 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml @@ -254,6 +254,18 @@ <output-dir compare="Text">connect-feed-with-aql-function</output-dir> </compilation-unit> </test-case> + <test-case FilePath="feeds"> + <compilation-unit name="disconnect-live-feed"> + <output-dir compare="Text">disconnect-live-feed</output-dir> + <expected-error>This operation cannot be done when Feed</expected-error> + </compilation-unit> + </test-case> + <test-case FilePath="feeds"> + <compilation-unit name="connect-live-feed"> + <output-dir compare="Text">connect-live-feed</output-dir> + <expected-error>This operation cannot be done when Feed</expected-error> + </compilation-unit> + </test-case> </test-group> <test-group name="upsert"> <test-case FilePath="upsert"> diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java index f521801..9de9dde 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java @@ -116,7 +116,7 @@ public static final int PARSER_HIVE_NULL_VALUE_IN_LIST = 3017; public static final int INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_NULL_IN_NON_OPTIONAL = 3018; public static final int INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_CANNT_GET_PKEY = 3019; - public static final int FEED_MANAGEMENT_FEED_EVENT_LISTENER_FEED_JOINT_REGISTERED = 3020; + public static final int FEED_CHANGE_FEED_CONNECTIVITY_ON_ALIVE_FEED = 3020; public static final int FEED_MANAGEMENT_FEED_EVENT_REGISTER_INTAKE_JOB_FAIL = 3021; public static final int PROVIDER_DATAFLOW_CONTROLLER_UNKNOWN_DATA_SOURCE = 3022; public static final int PROVIDER_DATASOURCE_FACTORY_UNKNOWN_INPUT_STREAM_FACTORY = 3023; diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties index 9e1ad76..b6423f6 100644 --- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties +++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties @@ -102,7 +102,7 @@ 3017 = can't parse hive list with null values 3018 = Field %1$s of meta record is not an optional type so it cannot accept null value. 3019 = Can't get PK from record part -3020 = Feed joint %1$s already registered +3020 = This operation cannot be done when Feed %1$s is alive. 3021 = Could not register feed intake job [%1$s] for feed %2$s 3022 = Unknown data source type: %1$s 3023 = Unknown input stream factory: %1$s -- To view, visit https://asterix-gerrit.ics.uci.edu/1664 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icbcc19da2a9f42bee21b52932ba4f19a0f01aeec Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Xikui Wang <xkk...@gmail.com>