Search in sources :

Example 11 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class TservConstraintEnvTest method testGetAuthorizationsContainer.

@Test
public void testGetAuthorizationsContainer() throws ThriftSecurityException {
    SecurityOperation security = createMock(SecurityOperation.class);
    TCredentials goodCred = createMock(TCredentials.class);
    TCredentials badCred = createMock(TCredentials.class);
    ByteSequence bs = new ArrayByteSequence("foo".getBytes());
    List<ByteBuffer> bbList = Collections.singletonList(ByteBuffer.wrap(bs.getBackingArray(), bs.offset(), bs.length()));
    expect(security.authenticatedUserHasAuthorizations(goodCred, bbList)).andReturn(true);
    expect(security.authenticatedUserHasAuthorizations(badCred, bbList)).andReturn(false);
    replay(security);
    assertTrue(new TservConstraintEnv(security, goodCred).getAuthorizationsContainer().contains(bs));
    assertFalse(new TservConstraintEnv(security, badCred).getAuthorizationsContainer().contains(bs));
}
Also used : TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) SecurityOperation(org.apache.accumulo.server.security.SecurityOperation) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteBuffer(java.nio.ByteBuffer) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Test(org.junit.Test)

Example 12 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileWriter method startNewLocalityGroup.

/**
 * Before appending any data, a locality group must be started. The default locality group must be started last.
 *
 * @param name
 *          locality group name, used for informational purposes
 * @param families
 *          the column families the locality group can contain
 *
 * @throws IllegalStateException
 *           When default locality group already started.
 */
public void startNewLocalityGroup(String name, List<byte[]> families) throws IOException {
    HashSet<ByteSequence> fams = new HashSet<>();
    for (byte[] family : families) {
        fams.add(new ArrayByteSequence(family));
    }
    _startNewLocalityGroup(name, fams);
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet)

Example 13 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileWriter method startNewLocalityGroup.

/**
 * See javadoc for {@link #startNewLocalityGroup(String, List)}.
 *
 * @param families
 *          will be encoded using UTF-8
 *
 * @throws IllegalStateException
 *           When default locality group already started.
 */
public void startNewLocalityGroup(String name, String... families) throws IOException {
    HashSet<ByteSequence> fams = new HashSet<>();
    for (String family : families) {
        fams.add(new ArrayByteSequence(family));
    }
    _startNewLocalityGroup(name, fams);
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet)

Example 14 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileWriter method append.

/**
 * Append the key and value to the last locality group that was started. If no locality group was started, then the default group will automatically be
 * started.
 *
 * @param key
 *          This key must be greater than or equal to the last key appended. For non-default locality groups, the keys column family must be one of the column
 *          families specified when calling startNewLocalityGroup(). Must be non-null.
 * @param val
 *          value to append, must be non-null.
 *
 * @throws IllegalArgumentException
 *           This is thrown when data is appended out of order OR when the key contains a invalid visibility OR when a column family is not valid for a
 *           locality group.
 */
public void append(Key key, Value val) throws IOException {
    if (!startedLG) {
        startDefaultLocalityGroup();
    }
    Boolean wasChecked = (Boolean) validVisibilities.get(key.getColumnVisibilityData());
    if (wasChecked == null) {
        byte[] cv = key.getColumnVisibilityData().toArray();
        new ColumnVisibility(cv);
        validVisibilities.put(new ArrayByteSequence(Arrays.copyOf(cv, cv.length)), Boolean.TRUE);
    }
    writer.append(key, val);
}
Also used : ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence)

Example 15 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class ConditionCheckerContext method buildIterator.

SortedKeyValueIterator<Key, Value> buildIterator(SortedKeyValueIterator<Key, Value> systemIter, TCondition tc) throws IOException {
    ArrayByteSequence key = new ArrayByteSequence(tc.iterators);
    MergedIterConfig mic = mergedIterCache.get(key);
    if (mic == null) {
        IterConfig ic = compressedIters.decompress(tc.iterators);
        List<IterInfo> mergedIters = new ArrayList<>(tableIters.size() + ic.ssiList.size());
        Map<String, Map<String, String>> mergedItersOpts = new HashMap<>(tableIterOpts.size() + ic.ssio.size());
        IteratorUtil.mergeIteratorConfig(mergedIters, mergedItersOpts, tableIters, tableIterOpts, ic.ssiList, ic.ssio);
        mic = new MergedIterConfig(mergedIters, mergedItersOpts);
        mergedIterCache.put(key, mic);
    }
    return IteratorUtil.loadIterators(systemIter, mic.mergedIters, mic.mergedItersOpts, tie, true, context, classCache);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) HashMap(java.util.HashMap) Map(java.util.Map) IterConfig(org.apache.accumulo.core.client.impl.CompressedIterators.IterConfig)

Aggregations

ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)39 ByteSequence (org.apache.accumulo.core.data.ByteSequence)26 HashSet (java.util.HashSet)20 Test (org.junit.Test)18 Key (org.apache.accumulo.core.data.Key)10 Value (org.apache.accumulo.core.data.Value)9 Range (org.apache.accumulo.core.data.Range)8 ArrayList (java.util.ArrayList)7 TreeMap (java.util.TreeMap)6 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)5 Text (org.apache.hadoop.io.Text)5 HashMap (java.util.HashMap)4 ColumnFamilySkippingIterator (org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Scanner (org.apache.accumulo.core.client.Scanner)2 Mutation (org.apache.accumulo.core.data.Mutation)2 PartialKey (org.apache.accumulo.core.data.PartialKey)2 IterInfo (org.apache.accumulo.core.data.thrift.IterInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1