Example usage for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexStatus

List of usage examples for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexStatus

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexStatus.

Prototype


public String getIndexStatus() 

Source Link

Document

The current state of the global secondary index:

  • CREATING - The index is being created.

    Usage

    From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate.java

    License:Open Source License

    public void waitForTableCreation(final String tableName, final boolean verifyIndexesList,
            final List<LocalSecondaryIndexDescription> expectedLsiList,
            final List<GlobalSecondaryIndexDescription> expectedGsiList) throws BackendException {
        boolean successFlag = false;
        int retryCount = 0;
        while (!successFlag && retryCount < maxRetries) {
            try {/*from ww  w. j a va 2  s.  co  m*/
                boolean areAllGsisActive = true;
                final TableDescription td = describeTable(tableName);
                if (verifyIndexesList) {
                    final Set<LocalSecondaryIndexDescription> expectedLSIs = new HashSet<LocalSecondaryIndexDescription>();
                    if (expectedLsiList != null) {
                        expectedLSIs.addAll(expectedLsiList);
                    }
                    final Set<LocalSecondaryIndexDescription> actualLSIs = new HashSet<LocalSecondaryIndexDescription>();
                    if (td.getLocalSecondaryIndexes() != null) {
                        actualLSIs.addAll(td.getLocalSecondaryIndexes());
                    }
                    // the lsi list should be there even if the table is in creating state
                    if (!(expectedLsiList == null && td.getLocalSecondaryIndexes() == null
                            || expectedLSIs.equals(actualLSIs))) {
                        throw new PermanentBackendException(
                                "LSI list is not as expected during table creation. expectedLsiList="
                                        + expectedLsiList.toString() + "; table description=" + td.toString());
                    }
    
                    // ignore the status of all GSIs since they will mess up .equals()
                    if (td.getGlobalSecondaryIndexes() != null) {
                        for (final GlobalSecondaryIndexDescription gDesc : td.getGlobalSecondaryIndexes()) {
                            if (!isTableAcceptingWrites(gDesc.getIndexStatus())) {
                                areAllGsisActive = false;
                                break;
                            }
                        }
                    }
    
                    // the gsi list should be there even if the table is in creating state
                    if (!areGsisSameConfiguration(expectedGsiList, td.getGlobalSecondaryIndexes())) {
                        throw new PermanentBackendException(
                                "GSI list is not as expected during table creation. expectedGsiList="
                                        + expectedGsiList.toString() + "; table description=" + td.toString());
                    }
                }
                successFlag = isTableAcceptingWrites(td.getTableStatus()) && areAllGsisActive;
            } catch (BackendNotFoundException ignore) {
                successFlag = false;
            }
    
            if (!successFlag) {
                interruptibleSleep(CONTROL_PLANE_RETRY_DELAY_MS);
            }
            retryCount++;
        }
        if (!successFlag) {
            throw new PermanentBackendException(
                    "Table creation not completed for table " + tableName + " after retrying " + this.maxRetries
                            + " times for a duration of " + CONTROL_PLANE_RETRY_DELAY_MS * this.maxRetries + " ms");
        }
    }
    

    From source file:com.rapid7.diskstorage.dynamodb.DynamoDBDelegate.java

    License:Open Source License

    public boolean waitForTableCreation(String tableName, boolean verifyIndexesList,
            List<LocalSecondaryIndexDescription> expectedLsiList,
            List<GlobalSecondaryIndexDescription> expectedGsiList) throws BackendException {
        boolean successFlag = false;
        int retryCount = 0;
        while (!successFlag && retryCount < maxRetries) {
            try {//  w w  w .j a va  2 s  . c  o  m
                boolean areAllGSIsActive = true;
                final TableDescription td = describeTable(tableName);
                if (verifyIndexesList) {
                    Set<LocalSecondaryIndexDescription> expectedLSIs = new HashSet<LocalSecondaryIndexDescription>();
                    if (expectedLsiList != null) {
                        expectedLSIs.addAll(expectedLsiList);
                    }
                    Set<LocalSecondaryIndexDescription> actualLSIs = new HashSet<LocalSecondaryIndexDescription>();
                    if (td.getLocalSecondaryIndexes() != null) {
                        actualLSIs.addAll(td.getLocalSecondaryIndexes());
                    }
                    // the lsi list should be there even if the table is in creating state
                    if (!((expectedLsiList == null && td.getLocalSecondaryIndexes() == null)
                            || expectedLSIs.equals(actualLSIs))) {
                        throw new PermanentBackendException(
                                "LSI list is not as expected during table creation. expectedLsiList="
                                        + expectedLsiList.toString() + "; table description=" + td.toString());
                    }
    
                    // ignore the status of all GSIs since they will mess up .equals()
                    if (td.getGlobalSecondaryIndexes() != null) {
                        for (GlobalSecondaryIndexDescription gDesc : td.getGlobalSecondaryIndexes()) {
                            if (!TableStatus.ACTIVE.toString().equals(gDesc.getIndexStatus())) {
                                areAllGSIsActive = false;
                                break;
                            }
                        }
                    }
    
                    // the gsi list should be there even if the table is in creating state
                    if (!areGSIsSameConfiguration(expectedGsiList, td.getGlobalSecondaryIndexes())) {
                        throw new PermanentBackendException(
                                "GSI list is not as expected during table creation. expectedGsiList="
                                        + expectedGsiList.toString() + "; table description=" + td.toString());
                    }
                }
                successFlag = td.getTableStatus().equals(TableStatus.ACTIVE.toString()) && areAllGSIsActive;
            } catch (BackendNotFoundException e) {
                successFlag = false;
            }
    
            if (!successFlag) {
                interruptibleSleep(CONTROL_PLANE_RETRY_DELAY_MS);
            }
            retryCount++;
        }
        if (!successFlag) {
            throw new PermanentBackendException(
                    "Table creation not completed for table " + tableName + " after retrying " + this.maxRetries
                            + " times for a duration of " + CONTROL_PLANE_RETRY_DELAY_MS * this.maxRetries + " ms");
        }
        return successFlag;
    }
    

    From source file:org.xmlsh.aws.util.AWSDDBCommand.java

    License:BSD License

    private void writeGlobalSecondaryIndex(GlobalSecondaryIndexDescription index) throws XMLStreamException {
    
        startElement("global-secondary-index");
        attribute("index-name", index.getIndexName());
        attribute("index-size", index.getIndexSizeBytes());
        attribute("index-status", index.getIndexStatus());
        attribute("item-count", index.getItemCount());
        writeKeySchemaList(index.getKeySchema());
        writeProjection(index.getProjection());
        writeProvisionedThroughput(index.getProvisionedThroughput());
        endElement();/* w ww  .j a va 2 s . co  m*/
    
    }