Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D45BC200C5D for ; Fri, 7 Apr 2017 19:28:38 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D2B52160B97; Fri, 7 Apr 2017 17:28:38 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 85E40160B84 for ; Fri, 7 Apr 2017 19:28:37 +0200 (CEST) Received: (qmail 93042 invoked by uid 500); 7 Apr 2017 17:28:36 -0000 Mailing-List: contact commits-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list commits@asterixdb.apache.org Received: (qmail 93029 invoked by uid 99); 7 Apr 2017 17:28:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Apr 2017 17:28:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F416FE00C5; Fri, 7 Apr 2017 17:28:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: xikui@apache.org To: commits@asterixdb.apache.org Message-Id: <5734443925814ce3bd717cbdb101a155@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: asterixdb git commit: Add test cases for alive feed check when connect/disconnect Date: Fri, 7 Apr 2017 17:28:35 +0000 (UTC) archived-at: Fri, 07 Apr 2017 17:28:39 -0000 Repository: asterixdb Updated Branches: refs/heads/master 246fbde6d -> 79abb7011 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 cases to check both exceptions. Change-Id: Icbcc19da2a9f42bee21b52932ba4f19a0f01aeec Reviewed-on: https://asterix-gerrit.ics.uci.edu/1664 Sonar-Qube: Jenkins Tested-by: Jenkins Integration-Tests: Jenkins Reviewed-by: Steven Jacobs Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/79abb701 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/79abb701 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/79abb701 Branch: refs/heads/master Commit: 79abb70110aa83c0f7983868bb6e89a9b8bd3913 Parents: 246fbde Author: Xikui Wang Authored: Wed Apr 5 17:31:23 2017 -0700 Committer: Xikui Wang Committed: Fri Apr 7 10:28:17 2017 -0700 ---------------------------------------------------------------------- .../asterix/app/translator/QueryTranslator.java | 11 ++++++ .../connect-live-feed.0.ddl.aql | 40 +++++++++++++++++++ .../connect-live-feed.1.update.aql | 21 ++++++++++ .../connect-live-feed.2.sleep.aql | 19 +++++++++ .../connect-live-feed.3.update.aql | 21 ++++++++++ .../disconnect-live-feed.0.ddl.aql | 41 ++++++++++++++++++++ .../disconnect-live-feed.1.update.aql | 21 ++++++++++ .../disconnect-live-feed.2.sleep.aql | 19 +++++++++ .../disconnect-live-feed.3.update.aql | 21 ++++++++++ .../src/test/resources/runtimets/testsuite.xml | 12 ++++++ .../asterix/common/exceptions/ErrorCode.java | 2 +- .../main/resources/asx_errormsg/en.properties | 2 +- 12 files changed, 228 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java ---------------------------------------------------------------------- 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.config.GlobalConfig; 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 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen 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 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen 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 { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.0.ddl.aql ---------------------------------------------------------------------- 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; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.1.update.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.2.sleep.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/connect-live-feed/connect-live-feed.3.update.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.0.ddl.aql ---------------------------------------------------------------------- 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; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.1.update.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.2.sleep.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/disconnect-live-feed/disconnect-live-feed.3.update.aql ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml ---------------------------------------------------------------------- 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 @@ connect-feed-with-aql-function + + + disconnect-live-feed + This operation cannot be done when Feed + + + + + connect-live-feed + This operation cannot be done when Feed + + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java ---------------------------------------------------------------------- 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 class ErrorCode { 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; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/79abb701/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties ---------------------------------------------------------------------- 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