You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@usergrid.apache.org by shawnfeldman <gi...@git.apache.org> on 2015/03/24 23:40:52 UTC
[GitHub] incubator-usergrid pull request: Usergrid 501 -
GitHub user shawnfeldman opened a pull request:
https://github.com/apache/incubator-usergrid/pull/199
Usergrid 501 -
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/incubator-usergrid USERGRID-501
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-usergrid/pull/199.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #199
----
commit cc779b24c6e8d19d6a20da85d2d625d8407b35eb
Author: Shawn Feldman <sf...@apache.org>
Date: 2015-03-23T16:53:20Z
add old type mapping to queries
commit 1a61e0eec82da613226396ab8cd533fd5353a89c
Author: Shawn Feldman <sf...@apache.org>
Date: 2015-03-23T17:16:41Z
remove array prefix
commit a9eafb8757988cb875f4677eaeeb261615ccc95f
Author: Shawn Feldman <sf...@apache.org>
Date: 2015-03-24T17:16:36Z
remove context
commit e0a79dbb24e1f9060b34c99effc3b966af4eaa56
Author: Shawn Feldman <sf...@apache.org>
Date: 2015-03-24T19:58:21Z
factor logic into index request
commit 90832ca0ccab39c6d170d7d42eae3314468f5d17
Author: Shawn Feldman <sf...@apache.org>
Date: 2015-03-24T22:18:56Z
change query to support legacy context
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-usergrid pull request: Usergrid 501 - migration for sing...
Posted by tnine <gi...@git.apache.org>.
Github user tnine commented on a diff in the pull request:
https://github.com/apache/incubator-usergrid/pull/199#discussion_r27404672
--- Diff: stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexMigrationTest.java ---
@@ -0,0 +1,106 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. 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. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+import com.google.inject.Inject;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.core.test.UseModules;
+import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.guice.TestIndexModule;
+import org.apache.usergrid.persistence.index.migration.EsIndexDataMigrationImpl;
+import org.apache.usergrid.persistence.index.migration.IndexDataVersions;
+import org.apache.usergrid.persistence.index.migration.LegacyIndexIdentifier;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.UUID;
+
+import static junit.framework.Assert.fail;
+import static junit.framework.TestCase.assertEquals;
+
+/**
+ * Classy class class.
+ */
+@RunWith(EsRunner.class)
+@UseModules({ TestIndexModule.class })
+public class IndexMigrationTest extends BaseIT{
+
+
+ @Inject
+ public IndexFig fig;
+ @Inject
+ public IndexIdentifier indexIdentifier;
+
+ @Inject
+ public IndexCache indexCache;
+
+ @Inject
+ public EsProvider provider;
+
+ @Inject
+ public AliasedEntityIndex ei;
+ @Inject
+ public IndexBufferProducer indexBatchBufferProducer;
+ @Inject
+ public MetricsFactory metricsFactory;
+
+ @Test
+ public void TestMigrate(){
+ EsIndexDataMigrationImpl indexDataMigration = new EsIndexDataMigrationImpl(ei,provider, fig, indexIdentifier,indexCache);
+ ProgressObserver po = new ProgressObserver() {
+ @Override
+ public void start() {
+
+ }
+
+ @Override
+ public void complete() {
+
+ }
+
+ @Override
+ public void failed(int migrationVersion, String reason) {
+ fail(reason);
+ }
+
+ @Override
+ public void failed(int migrationVersion, String reason, Throwable throwable) {
+ fail(reason);
+ }
+
+ @Override
+ public void update(int migrationVersion, String message) {
+
+ }
+ };
+
+ TestIndexModule.TestAllApplicationsObservable obs = new TestIndexModule.TestAllApplicationsObservable(indexBatchBufferProducer,provider,indexCache,metricsFactory,fig);
+ int version = indexDataMigration.migrate(0, obs, po );
+ assertEquals(version, IndexDataVersions.SINGLE_INDEX.getVersion());
--- End diff --
Can we read the indexes from ES and validate they have the read alias on them in this test too?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-usergrid pull request: Usergrid 501 - migration for sing...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-usergrid/pull/199
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-usergrid pull request: Usergrid 501 - migration for sing...
Posted by tnine <gi...@git.apache.org>.
Github user tnine commented on a diff in the pull request:
https://github.com/apache/incubator-usergrid/pull/199#discussion_r27404863
--- Diff: stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexDataMigrationImpl.java ---
@@ -0,0 +1,97 @@
+/*
+ * 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.usergrid.persistence.index.migration;
+
+import com.google.inject.Inject;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.VersionedData;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.index.AliasedEntityIndex;
+import org.apache.usergrid.persistence.index.IndexFig;
+import org.apache.usergrid.persistence.index.IndexIdentifier;
+import org.apache.usergrid.persistence.index.IndexCache;
+import org.apache.usergrid.persistence.index.impl.EsProvider;
+import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
+import org.elasticsearch.client.AdminClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import rx.Observable;
+
+/**
+ * Classy class class.
+ */
+public class EsIndexDataMigrationImpl implements DataMigration<ApplicationScope> {
+
+ private final AliasedEntityIndex entityIndex;
+ private final EsProvider provider;
+ private final IndexFig indexFig;
+ private final IndexIdentifier indexIdentifier;
+ private final IndexCache indexCache;
+ private final VersionedData dataVersion;
+ private static final Logger log = LoggerFactory.getLogger(EsIndexDataMigrationImpl.class);
+
+ @Inject
+ public EsIndexDataMigrationImpl(AliasedEntityIndex entityIndex, EsProvider provider, IndexFig indexFig, IndexIdentifier indexIdentifier, IndexCache indexCache){
+ this.entityIndex = entityIndex;
+ this.provider = provider;
+ this.indexFig = indexFig;
+ this.indexIdentifier = indexIdentifier;
+ this.indexCache = indexCache;
+ this.dataVersion = (VersionedData) entityIndex;
+ }
+
+ @Override
+ public int migrate(int currentVersion, MigrationDataProvider<ApplicationScope> migrationDataProvider, ProgressObserver observer) {
+ final AdminClient adminClient = provider.getClient().admin();
+ final int latestVersion = dataVersion.getImplementationVersion();
+
+ observer.start();
+ migrationDataProvider.getData().flatMap(applicationScope -> {
+ LegacyIndexIdentifier legacyIndexIdentifier = new LegacyIndexIdentifier(indexFig, applicationScope);
+ String[] indexes = indexCache.getIndexes(legacyIndexIdentifier.getAlias(), AliasedEntityIndex.AliasType.Read);
+ return Observable.from(indexes);
+ })
+ .doOnNext(index -> {
+ IndicesAliasesRequestBuilder aliasesRequestBuilder = adminClient.indices().prepareAliases();
+ aliasesRequestBuilder = adminClient.indices().prepareAliases();
+ // add read alias
+ aliasesRequestBuilder.addAlias(index, indexIdentifier.getAlias().getReadAlias());
+ observer.update(latestVersion,"EsIndexDataMigrationImpl: fixed index: " + index );
+ })
+ .doOnError(error -> {
--- End diff --
Lets only catch + swallow exceptions we expect. Otherwise this will fail silently and the migration with succeed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---