Java Code Examples for org.apache.hadoop.hbase.coprocessor.MasterObserver

The following examples show how to use org.apache.hadoop.hbase.coprocessor.MasterObserver. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: phoenix   Source File: PhoenixAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void preAlterTable(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId,
        String tableName, TableName physicalTableName, TableName parentPhysicalTableName, PTableType tableType) throws IOException {
    if (!accessCheckEnabled) { return; }
    for (MasterObserver observer : getAccessControllers()) {
        if (tableType != PTableType.VIEW) {
        observer.preModifyTable(getMasterObsevrverContext(), physicalTableName,
                TableDescriptorBuilder.newBuilder(physicalTableName).build());
        }
    }
    if (tableType == PTableType.VIEW) {
        if(execPermissionsCheckEnabled) {
            requireAccess("Alter "+tableType, parentPhysicalTableName, Action.READ, Action.EXEC);
        } else {
            requireAccess("Alter "+tableType, parentPhysicalTableName, Action.READ);
        }
    }
}
 
Example 2
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 6 votes vote down vote up
public void preStopMaster() throws IOException {
  // While stopping master all coprocessors method should be executed first then the coprocessor
  // environment should be cleaned up.
  if (coprocEnvironments.isEmpty()) {
    return;
  }
  execShutdown(new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preStopMaster(this);
    }
    @Override
    public void postEnvCall() {
      // invoke coprocessor stop method
      shutdown(this.getEnvironment());
    }
  });
}
 
Example 3
Source Project: phoenix   Source File: PhoenixAccessController.java    License: Apache License 2.0 6 votes vote down vote up
private List<MasterObserver> getAccessControllers() throws IOException {
    ArrayList<MasterObserver> oldAccessControllers = accessControllers.get();
    if (oldAccessControllers == null) {
        oldAccessControllers = new ArrayList<>();
        RegionCoprocessorHost cpHost = this.env.getCoprocessorHost();
        for (RegionCoprocessor cp : cpHost.findCoprocessors(RegionCoprocessor.class)) {
            if (cp instanceof AccessControlService.Interface && cp instanceof MasterObserver) {
                oldAccessControllers.add((MasterObserver)cp);
                if(cp.getClass().getName().equals(org.apache.hadoop.hbase.security.access.AccessController.class.getName())) {
                    hbaseAccessControllerEnabled = true;
                }
            }
        }
        accessControllers.set(oldAccessControllers);
    }
    return accessControllers.get();
}
 
Example 4
Source Project: phoenix   Source File: PhoenixAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void preIndexUpdate(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String tenantId,
        String indexName, TableName physicalTableName, TableName parentPhysicalTableName, PIndexState newState)
        throws IOException {
    if (!accessCheckEnabled) { return; }
    for (MasterObserver observer : getAccessControllers()) {
        observer.preModifyTable(getMasterObsevrverContext(), physicalTableName,
                TableDescriptorBuilder.newBuilder(physicalTableName).build());
    }
    // Check for read access in case of rebuild
    if (newState == PIndexState.BUILDING) {
        if(execPermissionsCheckEnabled) {
            requireAccess("Rebuild:", parentPhysicalTableName, Action.READ, Action.EXEC);
        } else {
            requireAccess("Rebuild:", parentPhysicalTableName, Action.READ);
        }
    }
}
 
Example 5
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preGetClusterMetrics() throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preGetClusterMetrics(this);
    }
  });
}
 
Example 6
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postSwitchRpcThrottle(final boolean oldValue, final boolean newValue)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postSwitchRpcThrottle(this, oldValue, newValue);
    }
  });
}
 
Example 7
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preGrant(UserPermission userPermission, boolean mergeExistingPermissions)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preGrant(this, userPermission, mergeExistingPermissions);
    }
  });
}
 
Example 8
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preGetTableNames(final List<TableDescriptor> descriptors,
    final String regex) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preGetTableNames(this, descriptors, regex);
    }
  });
}
 
Example 9
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preTransitReplicationPeerSyncReplicationState(String peerId,
    SyncReplicationState state) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preTransitReplicationPeerSyncReplicationState(this, peerId, state);
    }
  });
}
 
Example 10
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
  throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {

    @Override
    protected void call(MasterObserver observer) throws IOException {
      observer.postGetConfiguredNamespacesAndTablesInRSGroup(this, groupName);
    }
  });
}
 
Example 11
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postCreateNamespace(final NamespaceDescriptor ns) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postCreateNamespace(this, ns);
    }
  });
}
 
Example 12
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preDeleteNamespace(final String namespaceName) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preDeleteNamespace(this, namespaceName);
    }
  });
}
 
Example 13
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postDeleteNamespace(final String namespaceName) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postDeleteNamespace(this, namespaceName);
    }
  });
}
 
Example 14
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postMoveTables(final Set<TableName> tables, final String targetGroup)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postMoveTables(this, tables, targetGroup);
    }
  });
}
 
Example 15
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postRequestLock(String namespace, TableName tableName, RegionInfo[] regionInfos,
    LockType type, String description) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postRequestLock(this, namespace, tableName, regionInfos, description);
    }
  });
}
 
Example 16
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postGetNamespaceDescriptor(final NamespaceDescriptor ns)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postGetNamespaceDescriptor(this, ns);
    }
  });
}
 
Example 17
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preListNamespaces(final List<String> namespaces) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver oserver) throws IOException {
      oserver.preListNamespaces(this, namespaces);
    }
  });
}
 
Example 18
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preUpdateRSGroupConfig(final String groupName,
                                   final Map<String, String> configuration) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    protected void call(MasterObserver observer) throws IOException {
      observer.preUpdateRSGroupConfig(this, groupName, configuration);
    }
  });
}
 
Example 19
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postUpdateRSGroupConfig(final String groupName,
                                    final Map<String, String> configuration) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    protected void call(MasterObserver observer) throws IOException {
      observer.postUpdateRSGroupConfig(this, groupName, configuration);
    }
  });
}
 
Example 20
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preSwitchExceedThrottleQuota(boolean enable) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preSwitchExceedThrottleQuota(this, enable);
    }
  });
}
 
Example 21
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postCloneSnapshot(final SnapshotDescription snapshot,
    final TableDescriptor hTableDescriptor) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postCloneSnapshot(this, snapshot, hTableDescriptor);
    }
  });
}
 
Example 22
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postRevoke(UserPermission userPermission) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postRevoke(this, userPermission);
    }
  });
}
 
Example 23
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postCompletedCreateTableAction(
    final TableDescriptor htd, final RegionInfo[] regions, final User user) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postCompletedCreateTableAction(this, htd, regions);
    }
  });
}
 
Example 24
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postLockHeartbeat(LockProcedure proc, boolean keepAlive) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postLockHeartbeat(this);
    }
  });
}
 
Example 25
Source Project: phoenix   Source File: PhoenixAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void preCreateSchema(ObserverContext<PhoenixMetaDataControllerEnvironment> ctx, String schemaName)
        throws IOException {
    if (!accessCheckEnabled) { return; }
    for (MasterObserver observer : getAccessControllers()) {
        observer.preCreateNamespace(getMasterObsevrverContext(),
                NamespaceDescriptor.create(schemaName).build());
    }
}
 
Example 26
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postRemoveReplicationPeer(final String peerId) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postRemoveReplicationPeer(this, peerId);
    }
  });
}
 
Example 27
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postSetUserQuota(
    final String user, final TableName table, final GlobalQuotaSettings quotas)
        throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postSetUserQuota(this, user, table, quotas);
    }
  });
}
 
Example 28
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postTruncateTable(final TableName tableName) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postTruncateTable(this, tableName);
    }
  });
}
 
Example 29
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void preListReplicationPeers(final String regex) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preListReplicationPeers(this, regex);
    }
  });
}
 
Example 30
Source Project: hbase   Source File: MasterCoprocessorHost.java    License: Apache License 2.0 5 votes vote down vote up
public void postCompletedTruncateTableAction(final TableName tableName, final User user)
    throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation(user) {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postCompletedTruncateTableAction(this, tableName);
    }
  });
}