Search in sources :

Example 41 with Index

use of com.google.firestore.admin.v1.Index in project java-datastore by googleapis.

the class DatastoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockDatastoreAdmin.addResponse(expectedResponse);
    ListIndexesRequest request = ListIndexesRequest.newBuilder().setProjectId("projectId-894832108").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(request);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
    Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.datastore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.datastore.admin.v1.Index) ListIndexesRequest(com.google.datastore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 42 with Index

use of com.google.firestore.admin.v1.Index in project security by opensearch-project.

the class ConfigModelV7 method reload.

private SecurityRoles reload(SecurityDynamicConfiguration<RoleV7> settings) {
    final Set<Future<SecurityRole>> futures = new HashSet<>(5000);
    final ExecutorService execs = Executors.newFixedThreadPool(10);
    for (Entry<String, RoleV7> securityRole : settings.getCEntries().entrySet()) {
        Future<SecurityRole> future = execs.submit(new Callable<SecurityRole>() {

            @Override
            public SecurityRole call() throws Exception {
                SecurityRole.Builder _securityRole = new SecurityRole.Builder(securityRole.getKey());
                if (securityRole.getValue() == null) {
                    return null;
                }
                final Set<String> permittedClusterActions = agr.resolvedActions(securityRole.getValue().getCluster_permissions());
                _securityRole.addClusterPerms(permittedClusterActions);
                for (final Index permittedAliasesIndex : securityRole.getValue().getIndex_permissions()) {
                    final String dls = permittedAliasesIndex.getDls();
                    final List<String> fls = permittedAliasesIndex.getFls();
                    final List<String> maskedFields = permittedAliasesIndex.getMasked_fields();
                    for (String pat : permittedAliasesIndex.getIndex_patterns()) {
                        IndexPattern _indexPattern = new IndexPattern(pat);
                        _indexPattern.setDlsQuery(dls);
                        _indexPattern.addFlsFields(fls);
                        _indexPattern.addMaskedFields(maskedFields);
                        _indexPattern.addPerm(agr.resolvedActions(permittedAliasesIndex.getAllowed_actions()));
                        /*for(Entry<String, List<String>> type: permittedAliasesIndex.getValue().getTypes(-).entrySet()) {
                                    TypePerm typePerm = new TypePerm(type.getKey());
                                    final List<String> perms = type.getValue();
                                    typePerm.addPerms(agr.resolvedActions(perms));
                                    _indexPattern.addTypePerms(typePerm);
                                }*/
                        _securityRole.addIndexPattern(_indexPattern);
                    }
                }
                return _securityRole.build();
            }
        });
        futures.add(future);
    }
    execs.shutdown();
    try {
        execs.awaitTermination(30, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        log.error("Thread interrupted (1) while loading roles");
        return null;
    }
    try {
        SecurityRoles _securityRoles = new SecurityRoles(futures.size());
        for (Future<SecurityRole> future : futures) {
            _securityRoles.addSecurityRole(future.get());
        }
        return _securityRoles;
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        log.error("Thread interrupted (2) while loading roles");
        return null;
    } catch (ExecutionException e) {
        log.error("Error while updating roles: {}", e.getCause(), e.getCause());
        throw ExceptionsHelper.convertToOpenSearchException(e);
    }
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) SetMultimapBuilder(com.google.common.collect.MultimapBuilder.SetMultimapBuilder) Index(org.opensearch.security.securityconf.impl.v7.RoleV7.Index) RoleV7(org.opensearch.security.securityconf.impl.v7.RoleV7) ExecutionException(java.util.concurrent.ExecutionException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) List(java.util.List) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 43 with Index

use of com.google.firestore.admin.v1.Index in project jaxdb by jaxdb.

the class DerbyDecompiler method getIndexes.

@Override
@SuppressWarnings("null")
Map<String, $Table.Indexes> getIndexes(final Connection connection) throws SQLException {
    final Map<String, List<String>> tableNameToColumns = getTables(connection);
    final PreparedStatement statement = connection.prepareStatement(indexSql);
    final ResultSet rows = statement.executeQuery();
    final Map<String, $Table.Indexes> tableNameToIndexes = new HashMap<>();
    String lastTable = null;
    $Table.Indexes indexes = null;
    while (rows.next()) {
        final String tableName = rows.getString(2);
        final List<String> columnNames = tableNameToColumns.get(tableName);
        if (!tableName.equals(lastTable)) {
            lastTable = tableName;
            tableNameToIndexes.put(tableName, indexes = new $Table.Indexes());
        }
        final String descriptor = rows.getString(3);
        final boolean unique = descriptor.startsWith("UNIQUE");
        final $IndexType.Enum type = descriptor.startsWith("HASH") ? $Index.Type$.HASH : $Index.Type$.BTREE;
        final $Table.Indexes.Index index = new $Table.Indexes.Index();
        indexes.addIndex(index);
        if (!$Index.Type$.BTREE.equals(type))
            index.setType$(new $Index.Type$(type));
        if (unique)
            index.setUnique$(new $Index.Unique$(unique));
        final String[] columnNumbers = descriptor.substring(descriptor.lastIndexOf('(') + 1, descriptor.lastIndexOf(')')).split(",");
        for (final String columnNumber : columnNumbers) {
            final String columnName = columnNames.get(Integer.valueOf(columnNumber.trim()) - 1);
            final $Table.Indexes.Index.Column column = new $Table.Indexes.Index.Column();
            column.setName$(new $Table.Indexes.Index.Column.Name$(columnName.toLowerCase()));
            index.addColumn(column);
        }
    }
    return tableNameToIndexes;
}
Also used : HashMap(java.util.HashMap) PreparedStatement(java.sql.PreparedStatement) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$IndexType(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$IndexType) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List)

Example 44 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method getIndexTest2.

@Test
public void getIndexTest2() throws Exception {
    Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Index actualResponse = client.getIndex(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) GetIndexRequest(com.google.firestore.admin.v1.GetIndexRequest) Index(com.google.firestore.admin.v1.Index) Test(org.junit.Test)

Example 45 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method getIndexTest.

@Test
public void getIndexTest() throws Exception {
    Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
    Index actualResponse = client.getIndex(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : IndexName(com.google.firestore.admin.v1.IndexName) AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) GetIndexRequest(com.google.firestore.admin.v1.GetIndexRequest) Index(com.google.firestore.admin.v1.Index) Test(org.junit.Test)

Aggregations

Index (ucar.ma2.Index)30 Array (ucar.ma2.Array)20 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)15 AbstractMessage (com.google.protobuf.AbstractMessage)11 Attribute (ucar.nc2.Attribute)11 WritableRaster (java.awt.image.WritableRaster)10 IOException (java.io.IOException)10 ArrayFloat (ucar.ma2.ArrayFloat)10 Index (com.google.firestore.admin.v1.Index)9 Dimension (ucar.nc2.Dimension)9 NetcdfFileWriteable (ucar.nc2.NetcdfFileWriteable)8 Variable (ucar.nc2.Variable)8 ArrayDouble (ucar.ma2.ArrayDouble)7 NetcdfFile (ucar.nc2.NetcdfFile)7 SampleModel (java.awt.image.SampleModel)5 Index (com.google.datastore.admin.v1.Index)4 IndexName (com.google.firestore.admin.v1.IndexName)4 Operation (com.google.longrunning.Operation)4 File (java.io.File)4