HBASE-23627 Resolved remaining Checkstyle violations in hbase-thrift
Signed-off-by: Viraj Jasani <vjasani@apache.org> Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
17652a7b32
commit
a18a5c4baa
|
@ -15,7 +15,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.thrift;
|
package org.apache.hadoop.hbase.thrift;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,7 +34,6 @@ import org.apache.hadoop.hbase.thrift.generated.TIncrement;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.util.Threads;
|
import org.apache.hadoop.hbase.util.Threads;
|
||||||
import org.apache.hadoop.metrics2.util.MBeans;
|
import org.apache.hadoop.metrics2.util.MBeans;
|
||||||
import org.apache.thrift.TException;
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -51,7 +49,6 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class IncrementCoalescer implements IncrementCoalescerMBean {
|
public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to identify a cell that will be incremented.
|
* Used to identify a cell that will be incremented.
|
||||||
*
|
*
|
||||||
|
@ -82,10 +79,6 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
return rowKey;
|
return rowKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRowKey(byte[] rowKey) {
|
|
||||||
this.rowKey = rowKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getFamily() {
|
public byte[] getFamily() {
|
||||||
return family;
|
return family;
|
||||||
}
|
}
|
||||||
|
@ -119,13 +112,19 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
if (obj == null) return false;
|
if (obj == null) return false;
|
||||||
if (getClass() != obj.getClass()) return false;
|
if (getClass() != obj.getClass()) return false;
|
||||||
FullyQualifiedRow other = (FullyQualifiedRow) obj;
|
FullyQualifiedRow other = (FullyQualifiedRow) obj;
|
||||||
if (!Arrays.equals(family, other.family)) return false;
|
|
||||||
if (!Arrays.equals(qualifier, other.qualifier)) return false;
|
|
||||||
if (!Arrays.equals(rowKey, other.rowKey)) return false;
|
|
||||||
if (!Arrays.equals(table, other.table)) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!Arrays.equals(family, other.family)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Arrays.equals(qualifier, other.qualifier)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Arrays.equals(rowKey, other.rowKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.equals(table, other.table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LongAdder failedIncrements = new LongAdder();
|
private final LongAdder failedIncrements = new LongAdder();
|
||||||
|
@ -139,9 +138,8 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
private int maxQueueSize = 500000;
|
private int maxQueueSize = 500000;
|
||||||
private static final int CORE_POOL_SIZE = 1;
|
private static final int CORE_POOL_SIZE = 1;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(FullyQualifiedRow.class);
|
private static final Logger LOG = LoggerFactory.getLogger(IncrementCoalescer.class);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public IncrementCoalescer(ThriftHBaseServiceHandler hand) {
|
public IncrementCoalescer(ThriftHBaseServiceHandler hand) {
|
||||||
this.handler = hand;
|
this.handler = hand;
|
||||||
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
|
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
|
||||||
|
@ -151,7 +149,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
MBeans.register("thrift", "Thrift", this);
|
MBeans.register("thrift", "Thrift", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queueIncrement(TIncrement inc) throws TException {
|
public boolean queueIncrement(TIncrement inc) {
|
||||||
if (!canQueue()) {
|
if (!canQueue()) {
|
||||||
failedIncrements.increment();
|
failedIncrements.increment();
|
||||||
return false;
|
return false;
|
||||||
|
@ -159,7 +157,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
return internalQueueTincrement(inc);
|
return internalQueueTincrement(inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queueIncrements(List<TIncrement> incs) throws TException {
|
public boolean queueIncrements(List<TIncrement> incs) {
|
||||||
if (!canQueue()) {
|
if (!canQueue()) {
|
||||||
failedIncrements.increment();
|
failedIncrements.increment();
|
||||||
return false;
|
return false;
|
||||||
|
@ -172,7 +170,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean internalQueueTincrement(TIncrement inc) throws TException {
|
private boolean internalQueueTincrement(TIncrement inc) {
|
||||||
byte[][] famAndQf = CellUtil.parseColumn(inc.getColumn());
|
byte[][] famAndQf = CellUtil.parseColumn(inc.getColumn());
|
||||||
if (famAndQf.length != 2) return false;
|
if (famAndQf.length != 2) return false;
|
||||||
|
|
||||||
|
@ -182,7 +180,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
|
|
||||||
@SuppressWarnings("FutureReturnValueIgnored")
|
@SuppressWarnings("FutureReturnValueIgnored")
|
||||||
private boolean internalQueueIncrement(byte[] tableName, byte[] rowKey, byte[] fam,
|
private boolean internalQueueIncrement(byte[] tableName, byte[] rowKey, byte[] fam,
|
||||||
byte[] qual, long ammount) throws TException {
|
byte[] qual, long ammount) {
|
||||||
int countersMapSize = countersMap.size();
|
int countersMapSize = countersMap.size();
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
Long value = countersMap.remove(key);
|
Long value = countersMap.remove(key);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// There was nothing there, create a new value
|
// There was nothing there, create a new value
|
||||||
value = Long.valueOf(currentAmount);
|
value = currentAmount;
|
||||||
} else {
|
} else {
|
||||||
value += currentAmount;
|
value += currentAmount;
|
||||||
successfulCoalescings.increment();
|
successfulCoalescings.increment();
|
||||||
|
@ -232,39 +230,36 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Callable<Integer> createIncCallable() {
|
private Callable<Integer> createIncCallable() {
|
||||||
return new Callable<Integer>() {
|
return () -> {
|
||||||
@Override
|
int failures = 0;
|
||||||
public Integer call() throws Exception {
|
Set<FullyQualifiedRow> keys = countersMap.keySet();
|
||||||
int failures = 0;
|
for (FullyQualifiedRow row : keys) {
|
||||||
Set<FullyQualifiedRow> keys = countersMap.keySet();
|
Long counter = countersMap.remove(row);
|
||||||
for (FullyQualifiedRow row : keys) {
|
if (counter == null) {
|
||||||
Long counter = countersMap.remove(row);
|
continue;
|
||||||
if (counter == null) {
|
}
|
||||||
continue;
|
Table table = null;
|
||||||
|
try {
|
||||||
|
table = handler.getTable(row.getTable());
|
||||||
|
if (failures > 2) {
|
||||||
|
throw new IOException("Auto-Fail rest of ICVs");
|
||||||
}
|
}
|
||||||
Table table = null;
|
table.incrementColumnValue(row.getRowKey(), row.getFamily(), row.getQualifier(),
|
||||||
try {
|
counter);
|
||||||
table = handler.getTable(row.getTable());
|
} catch (IOException e) {
|
||||||
if (failures > 2) {
|
// log failure of increment
|
||||||
throw new IOException("Auto-Fail rest of ICVs");
|
failures++;
|
||||||
}
|
LOG.error("FAILED_ICV: " + Bytes.toString(row.getTable()) + ", "
|
||||||
table.incrementColumnValue(row.getRowKey(), row.getFamily(), row.getQualifier(),
|
+ Bytes.toStringBinary(row.getRowKey()) + ", "
|
||||||
counter);
|
+ Bytes.toStringBinary(row.getFamily()) + ", "
|
||||||
} catch (IOException e) {
|
+ Bytes.toStringBinary(row.getQualifier()) + ", " + counter, e);
|
||||||
// log failure of increment
|
} finally{
|
||||||
failures++;
|
if(table != null){
|
||||||
LOG.error("FAILED_ICV: " + Bytes.toString(row.getTable()) + ", "
|
table.close();
|
||||||
+ Bytes.toStringBinary(row.getRowKey()) + ", "
|
|
||||||
+ Bytes.toStringBinary(row.getFamily()) + ", "
|
|
||||||
+ Bytes.toStringBinary(row.getQualifier()) + ", " + counter, e);
|
|
||||||
} finally{
|
|
||||||
if(table != null){
|
|
||||||
table.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return failures;
|
|
||||||
}
|
}
|
||||||
|
return failures;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,5 +364,4 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
|
||||||
public long getCountersMapSize() {
|
public long getCountersMapSize() {
|
||||||
return countersMap.size();
|
return countersMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
|
||||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.Hbase;
|
import org.apache.hadoop.hbase.thrift.generated.Hbase;
|
||||||
import org.apache.hadoop.hbase.util.TableDescriptorChecker;
|
|
||||||
import org.apache.hadoop.security.authentication.util.KerberosName;
|
import org.apache.hadoop.security.authentication.util.KerberosName;
|
||||||
import org.apache.http.HttpHeaders;
|
import org.apache.http.HttpHeaders;
|
||||||
import org.apache.http.auth.AuthSchemeProvider;
|
import org.apache.http.auth.AuthSchemeProvider;
|
||||||
|
@ -212,29 +211,26 @@ public class TestThriftSpnegoHttpFallbackServer extends TestThriftHttpServer {
|
||||||
// The name of the principal
|
// The name of the principal
|
||||||
final String clientPrincipalName = clientPrincipals.iterator().next().getName();
|
final String clientPrincipalName = clientPrincipals.iterator().next().getName();
|
||||||
|
|
||||||
return Subject.doAs(clientSubject, new PrivilegedExceptionAction<CloseableHttpClient>() {
|
return Subject.doAs(clientSubject, (PrivilegedExceptionAction<CloseableHttpClient>) () -> {
|
||||||
@Override
|
// Logs in with Kerberos via GSS
|
||||||
public CloseableHttpClient run() throws Exception {
|
GSSManager gssManager = GSSManager.getInstance();
|
||||||
// Logs in with Kerberos via GSS
|
// jGSS Kerberos login constant
|
||||||
GSSManager gssManager = GSSManager.getInstance();
|
Oid oid = new Oid("1.2.840.113554.1.2.2");
|
||||||
// jGSS Kerberos login constant
|
GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
|
||||||
Oid oid = new Oid("1.2.840.113554.1.2.2");
|
GSSCredential credential = gssManager.createCredential(gssClient,
|
||||||
GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
|
GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
|
||||||
GSSCredential credential = gssManager.createCredential(gssClient,
|
|
||||||
GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
|
|
||||||
|
|
||||||
Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
|
Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
|
||||||
.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
|
.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||||
credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
|
credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
|
||||||
|
|
||||||
return HttpClients.custom()
|
return HttpClients.custom()
|
||||||
.setDefaultAuthSchemeRegistry(authRegistry)
|
.setDefaultAuthSchemeRegistry(authRegistry)
|
||||||
.setDefaultCredentialsProvider(credentialsProvider)
|
.setDefaultCredentialsProvider(credentialsProvider)
|
||||||
.build();
|
.build();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
|
||||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.Hbase;
|
import org.apache.hadoop.hbase.thrift.generated.Hbase;
|
||||||
import org.apache.hadoop.hbase.util.TableDescriptorChecker;
|
|
||||||
import org.apache.hadoop.security.authentication.util.KerberosName;
|
import org.apache.hadoop.security.authentication.util.KerberosName;
|
||||||
import org.apache.http.HttpHeaders;
|
import org.apache.http.HttpHeaders;
|
||||||
import org.apache.http.auth.AuthSchemeProvider;
|
import org.apache.http.auth.AuthSchemeProvider;
|
||||||
|
@ -211,29 +210,26 @@ public class TestThriftSpnegoHttpServer extends TestThriftHttpServer {
|
||||||
// The name of the principal
|
// The name of the principal
|
||||||
final String clientPrincipalName = clientPrincipals.iterator().next().getName();
|
final String clientPrincipalName = clientPrincipals.iterator().next().getName();
|
||||||
|
|
||||||
return Subject.doAs(clientSubject, new PrivilegedExceptionAction<CloseableHttpClient>() {
|
return Subject.doAs(clientSubject, (PrivilegedExceptionAction<CloseableHttpClient>) () -> {
|
||||||
@Override
|
// Logs in with Kerberos via GSS
|
||||||
public CloseableHttpClient run() throws Exception {
|
GSSManager gssManager = GSSManager.getInstance();
|
||||||
// Logs in with Kerberos via GSS
|
// jGSS Kerberos login constant
|
||||||
GSSManager gssManager = GSSManager.getInstance();
|
Oid oid = new Oid("1.2.840.113554.1.2.2");
|
||||||
// jGSS Kerberos login constant
|
GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
|
||||||
Oid oid = new Oid("1.2.840.113554.1.2.2");
|
GSSCredential credential = gssManager.createCredential(gssClient,
|
||||||
GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
|
GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
|
||||||
GSSCredential credential = gssManager.createCredential(gssClient,
|
|
||||||
GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
|
|
||||||
|
|
||||||
Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
|
Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
|
||||||
.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
|
.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||||
credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
|
credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
|
||||||
|
|
||||||
return HttpClients.custom()
|
return HttpClients.custom()
|
||||||
.setDefaultAuthSchemeRegistry(authRegistry)
|
.setDefaultAuthSchemeRegistry(authRegistry)
|
||||||
.setDefaultCredentialsProvider(credentialsProvider)
|
.setDefaultCredentialsProvider(credentialsProvider)
|
||||||
.build();
|
.build();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue