You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/03/19 23:19:56 UTC

[06/50] [abbrv] incubator-usergrid git commit: Added new example interfaces

Added new example interfaces


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6652fe58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6652fe58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6652fe58

Branch: refs/heads/USERGRID-493
Commit: 6652fe581a91e52faee3508860a75795b320cbfd
Parents: 9589775
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 26 16:54:00 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 26 16:54:00 2015 -0700

----------------------------------------------------------------------
 .../migration/data/newimpls/DataMigration2.java | 71 ++++++++++++++++++++
 .../data/newimpls/MigrationDataProvider.java    | 43 ++++++++++++
 .../data/newimpls/MigrationPlugin.java          | 47 +++++++++++++
 3 files changed, 161 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6652fe58/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
new file mode 100644
index 0000000..f660c02
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
@@ -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.usergrid.persistence.core.migration.data.newimpls;
+
+
+/**
+ * Data migration.  The internal version to migrate
+ *
+ * @param <T>
+ */
+public interface DataMigration2<T> {
+
+    /**
+     * Perform the migration, returning an observable with a single emitted value
+     * @param migrationDataProvider
+     */
+    public void migrate(MigrationDataProvider<T> migrationDataProvider, ProgressObserver observer);
+
+    /**
+     * Get the version of this migration. It should be unique within the scope of the plugin
+     * @return
+     */
+    public int version();
+
+
+    public interface ProgressObserver{
+            /**
+             * Mark the migration as failed
+             * @param migrationVersion The migration version running during the failure
+             * @param reason The reason to save
+             */
+            public void failed(final int migrationVersion, final String reason);
+
+            /**
+             * Mark the migration as failed with a stack trace
+             * @param migrationVersion The migration version running during the failure
+             * @param reason The error description to save
+             * @param throwable The error that happened
+             */
+            public void failed(final int migrationVersion, final String reason, final Throwable throwable);
+
+
+            /**
+             * Update the status of the migration with the message
+             *
+             * @param message The message to save for the status
+             */
+            public void update(final int migrationVersion, final String message);
+        }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6652fe58/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationDataProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationDataProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationDataProvider.java
new file mode 100644
index 0000000..ffe8d9e
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationDataProvider.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  *
+ *  * 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.core.migration.data.newimpls;
+
+
+import rx.Observable;
+
+
+/**
+ * An interface for data providers to implement.  The migration must take the migrationdata provider as an argument
+ * @param <T>
+ */
+public interface MigrationDataProvider<T> {
+
+
+    /**
+     * Get data that can be used in the migration
+     * @return
+     */
+    public Observable<T> getData();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6652fe58/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationPlugin.java
new file mode 100644
index 0000000..f04a035
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/MigrationPlugin.java
@@ -0,0 +1,47 @@
+/*
+ *
+ *  *
+ *  * 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.core.migration.data.newimpls;
+
+
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+
+
+/**
+ * A simple interface to return migration plugins.  All versions within this migration plugin should have a name
+ */
+public interface MigrationPlugin {
+
+
+    /**
+     * Get the name of the plugin
+     * @return
+     */
+    public String getName();
+
+    /**
+     * Run any migrations that may need to be run in this plugin
+     */
+    public void run(DataMigration.ProgressObserver observer);
+
+}