Github user GERey commented on a diff in the pull request:
https://github.com/apache/incubator-usergrid/pull/187#discussion_r26678325
--- Diff:
stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
---
@@ -261,60 +257,51 @@ public void addIndex(final String indexSuffix,final
int numberOfShards, final in
@Override
public void addAlias(final String indexSuffix) {
+
+ final Timer.Context timeRemoveAlias = updateAliasTimer.time();
try {
- Boolean isAck;
- String indexName = indexIdentifier.getIndex(indexSuffix);
- final AdminClient adminClient = esProvider.getClient().admin();
- String[] indexNames = getIndexes(AliasType.Write);
- for ( String currentIndex : indexNames ) {
+ String indexName = indexIdentifier.getIndex(indexSuffix);
+ final AdminClient adminClient = esProvider.getClient().admin();
- final Timer.Context timeRemoveAlias =
removeAliasTimer.time();
+ String[] indexNames = getIndexesFromEs( AliasType.Write );
- try {
- //Added For Graphite Metrics
- isAck =
adminClient.indices().prepareAliases().removeAlias( currentIndex,
alias.getWriteAlias() )
-
.execute().actionGet().isAcknowledged();
+ final IndicesAliasesRequestBuilder aliasesRequestBuilder =
adminClient.indices().prepareAliases();
- logger.info( "Removed Index Name [{}] from Alias=[{}]
ACK=[{}]", currentIndex, alias, isAck );
- }
- catch ( AliasesMissingException aie ) {
- logger.info( "Alias does not exist Index Name [{}]
from Alias=[{}] ACK=[{}]", currentIndex, alias,
- aie.getMessage() );
- continue;
- }
- catch ( InvalidAliasNameException iane ) {
- logger.info( "Alias does not exist Index Name [{}]
from Alias=[{}] ACK=[{}]", currentIndex, alias,
- iane.getMessage() );
- continue;
- }
- finally {
- timeRemoveAlias.stop();
- }
+ //remove the write alias from it's target
+ for ( String currentIndex : indexNames ) {
+ aliasesRequestBuilder.removeAlias( currentIndex,
alias.getWriteAlias() );
+ logger.info("Removing existing write Alias Name [{}] from
Index [{}]", alias.getReadAlias(), currentIndex);
}
//Added For Graphite Metrics
- Timer.Context timeAddReadAlias = addReadAliasTimer.time();
+
// add read alias
- isAck = adminClient.indices().prepareAliases().addAlias(
- indexName,
alias.getReadAlias()).execute().actionGet().isAcknowledged();
- timeAddReadAlias.stop();
- logger.info("Created new read Alias Name [{}] ACK=[{}]",
alias.getReadAlias(), isAck);
+ aliasesRequestBuilder.addAlias( indexName,
alias.getReadAlias());
+ logger.info("Created new read Alias Name [{}] on Index [{}]",
alias.getReadAlias(), indexName);
+
- //Added For Graphite Metrics
- Timer.Context timeAddWriteAlias = addWriteAliasTimer.time();
--- End diff --
Do these metrics not work? Otherwise why should we take them out?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---