Renamed PR to match org.apache
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3cd006ac Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3cd006ac Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3cd006ac Branch: refs/pull/27/head Commit: 3cd006acb15c3b3216255d641c8b47c83e85bba6 Parents: d565e79 Author: Todd Nine <[email protected]> Authored: Fri Mar 7 09:25:05 2014 -0700 Committer: Todd Nine <[email protected]> Committed: Fri Mar 7 09:25:30 2014 -0700 ---------------------------------------------------------------------- .../RepairingMismatchedApplicationMetadata.java | 73 ++++++++++++++++++++ .../RepairingMismatchedApplicationMetadata.java | 57 --------------- 2 files changed, 73 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3cd006ac/stack/tools/src/main/java/org/apache/usergrid/tools/RepairingMismatchedApplicationMetadata.java ---------------------------------------------------------------------- diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/RepairingMismatchedApplicationMetadata.java b/stack/tools/src/main/java/org/apache/usergrid/tools/RepairingMismatchedApplicationMetadata.java new file mode 100644 index 0000000..c0bd320 --- /dev/null +++ b/stack/tools/src/main/java/org/apache/usergrid/tools/RepairingMismatchedApplicationMetadata.java @@ -0,0 +1,73 @@ +/* + * 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.tools; + +import com.google.common.collect.BiMap; +import me.prettyprint.cassandra.serializers.ByteBufferSerializer; +import me.prettyprint.hector.api.Keyspace; +import me.prettyprint.hector.api.mutation.Mutator; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; + +import java.nio.ByteBuffer; +import java.util.Map; +import java.util.UUID; + +import static me.prettyprint.hector.api.factory.HFactory.createMutator; +import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME; +import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID; +import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator; +import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute; +import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF; +import static org.apache.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT; + +public class RepairingMismatchedApplicationMetadata extends ToolBase { + + public static final ByteBufferSerializer be = new ByteBufferSerializer(); + + @Override + public Options createOptions() { + Options options = super.createOptions(); + return options; + } + + @Override + public void runTool(CommandLine line) throws Exception { + startSpring(); + + BiMap<UUID, String> orgs = managementService.getOrganizations(); + for(Map.Entry org : orgs.entrySet()) { + BiMap<UUID, String> apps = managementService.getApplicationsForOrganization((UUID)org.getKey()); + for(Map.Entry app : apps.entrySet()) { + UUID applicationId = emf.lookupApplication((String)app.getValue()); + if( applicationId == null ) { + String appName = (String)app.getValue(); + Keyspace ko = cass.getSystemKeyspace(); + Mutator<ByteBuffer> m = createMutator(ko, be); + long timestamp = cass.createTimestamp(); + addInsertToMutator(m, APPLICATIONS_CF, appName, PROPERTY_UUID, (UUID)app.getKey(), timestamp); + addInsertToMutator(m, APPLICATIONS_CF, appName, PROPERTY_NAME, appName, timestamp); + batchExecute(m, RETRY_COUNT); + logger.info("UUID {}, NAME {}", app.getKey(), app.getValue()); + } + } + } + + logger.info("Waiting 60 sec..."); + Thread.sleep(1000 * 60); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3cd006ac/stack/tools/src/main/java/org/usergrid/tools/RepairingMismatchedApplicationMetadata.java ---------------------------------------------------------------------- diff --git a/stack/tools/src/main/java/org/usergrid/tools/RepairingMismatchedApplicationMetadata.java b/stack/tools/src/main/java/org/usergrid/tools/RepairingMismatchedApplicationMetadata.java deleted file mode 100644 index 24146fc..0000000 --- a/stack/tools/src/main/java/org/usergrid/tools/RepairingMismatchedApplicationMetadata.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.usergrid.tools; - -import com.google.common.collect.BiMap; -import me.prettyprint.cassandra.serializers.ByteBufferSerializer; -import me.prettyprint.hector.api.Keyspace; -import me.prettyprint.hector.api.mutation.Mutator; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Options; - -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.UUID; - -import static me.prettyprint.hector.api.factory.HFactory.createMutator; -import static org.usergrid.persistence.Schema.PROPERTY_NAME; -import static org.usergrid.persistence.Schema.PROPERTY_UUID; -import static org.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator; -import static org.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute; -import static org.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF; -import static org.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT; - -public class RepairingMismatchedApplicationMetadata extends ToolBase { - - public static final ByteBufferSerializer be = new ByteBufferSerializer(); - - @Override - public Options createOptions() { - Options options = super.createOptions(); - return options; - } - - @Override - public void runTool(CommandLine line) throws Exception { - startSpring(); - - BiMap<UUID, String> orgs = managementService.getOrganizations(); - for(Map.Entry org : orgs.entrySet()) { - BiMap<UUID, String> apps = managementService.getApplicationsForOrganization((UUID)org.getKey()); - for(Map.Entry app : apps.entrySet()) { - UUID applicationId = emf.lookupApplication((String)app.getValue()); - if( applicationId == null ) { - String appName = (String)app.getValue(); - Keyspace ko = cass.getSystemKeyspace(); - Mutator<ByteBuffer> m = createMutator(ko, be); - long timestamp = cass.createTimestamp(); - addInsertToMutator(m, APPLICATIONS_CF, appName, PROPERTY_UUID, (UUID)app.getKey(), timestamp); - addInsertToMutator(m, APPLICATIONS_CF, appName, PROPERTY_NAME, appName, timestamp); - batchExecute(m, RETRY_COUNT); - logger.info("UUID {}, NAME {}", app.getKey(), app.getValue()); - } - } - } - - logger.info("Waiting 60 sec..."); - Thread.sleep(1000 * 60); - } -}
