diff -uNr src/org/apache/hbase/tmpl/table/changepriority.jamon src/org/apache/hbase/tmpl/table/changepriority.jamon --- src/org/apache/hbase/tmpl/table/changepriority.jamon (revision 0) +++ src/org/apache/hbase/tmpl/table/changepriority.jamon (working copy) @@ -0,0 +1,183 @@ +<%doc> +Copyright 2011 The Apache Software Foundation + +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +<%import> +import="org.apache.hadoop.conf.Configuration" +import="org.apache.hadoop.hbase.HBaseConfiguration" +import="org.apache.hadoop.hbase.HTableDescriptor" +import="org.apache.hadoop.hbase.MasterNotRunningException" +import="org.apache.hadoop.hbase.ZooKeeperConnectionException" +import="org.apache.hadoop.hbase.master.HMaster" +import="org.apache.hadoop.hbase.client.HBaseAdmin" +import="org.apache.hadoop.hbase.ipc.PriorityHBaseServer" +import="org.apache.hadoop.hbase.ipc.PriorityFunction" +import="org.apache.hadoop.hbase.ipc.PriorityJobQueue" +import="org.apache.hadoop.hbase.util.Bytes" + + + + + +Change Priority + + + + + +

Change Priority

+ +
+<%java> + class ChangePriorityThread extends Thread { + private HBaseAdmin admin; + private String tablename; + private String tablepri; + private String scanpri; + private String putpri; + private String getpri; + private String delpri; + + public ChangePriorityThread(HBaseAdmin admin, String tablename, + String tablepri, String scanpri, String putpri, String getpri, + String delpri) { + this.admin = admin; + this.tablename = tablename; + this.tablepri = tablepri; + this.scanpri = scanpri; + this.putpri = putpri; + this.getpri = getpri; + this.delpri = delpri; + } + + public void run() { + synchronized (tablename) { + HTableDescriptor table = null; + try { + if (!admin.isTableDisabled(Bytes.toBytes(tablename))) { + admin.disableTable(tablename); + } + table = admin.getTableDescriptor(Bytes.toBytes(tablename)); + } catch (IOException e) { + } + byte[] origintablepri = table.getValue(PriorityFunction.PRI_KEY); + PriorityJobQueue.ActionPriorities originaction = PriorityFunction.getTableActionPriorities(table); + int originscanprival = originaction.getScanPlus(); + int originputprival = originaction.getPutPlus(); + int origingetprival = originaction.getGetPlus(); + int origindelprival = originaction.getDeletePlus(); + + String tableprival = null; + if (tablepri == null || tablepri.length() <= 0) { + if (origintablepri == null + || Bytes.toString(origintablepri).length() <= 0) { + tableprival = (new Integer(PriorityFunction.DEFAULT_PRI)) + .toString(); + } else { + tableprival = Bytes.toString(origintablepri); + } + } else { + tableprival = tablepri; + } + PriorityFunction.setPriority(tableprival,table); + try { + int scanprival = (scanpri == null || scanpri.length() <= 0) ? originscanprival + : Integer.valueOf(scanpri); + int putprival = (putpri == null || putpri.length() <= 0) ? originputprival + : Integer.valueOf(putpri); + int getprival = (getpri == null || getpri.length() <= 0) ? origingetprival + : Integer.valueOf(getpri); + int delprival = (delpri == null || delpri.length() <= 0) ? origindelprival + : Integer.valueOf(delpri); + table.setValue(PriorityFunction.PRI_KEY_ACTION_PLUS, + new PriorityJobQueue.ActionPriorities(scanprival, + putprival, getprival, delprival).toBytes()); + admin.modifyTable(Bytes.toBytes(tablename), table); + } catch (IOException e) { + } + try { + admin.enableTable(tablename); + } catch (IOException ex) { + } + } + } + } + +

Change priority

+<%java> + String tablename = request.getParameter("tablename"); + String tablepri = request.getParameter("tablepri"); + String scanpri = request.getParameter("scanpri"); + String putpri = request.getParameter("putpri"); + String getpri = request.getParameter("getpri"); + String delpri = request.getParameter("delpri"); + try { + int checkformat = 0; + if (tablepri != null && tablepri.length() > 0) { + checkformat = Integer.valueOf(tablepri); + } + if (scanpri != null && scanpri.length() > 0) { + checkformat = Integer.valueOf(scanpri); + } + if (putpri != null && putpri.length() > 0) { + checkformat = Integer.valueOf(putpri); + } + if (getpri != null && getpri.length() > 0) { + checkformat = Integer.valueOf(getpri); + } + if (delpri != null && delpri.length() > 0) { + checkformat = Integer.valueOf(delpri); + } + } catch (Exception e) { + + +<%java> + return; + } + HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER); + HBaseAdmin admin = null; + try { + admin = new HBaseAdmin(master.getConfiguration()); + if (!admin.tableExists(Bytes.toBytes(tablename))) { + return; + } + } catch (Exception e) { + out.println("Can't connect hbase ,check carefullt!"); + return; + } + +<%if !admin.tableExists(Bytes.toBytes(tablename)) %> +This table <% tablename %> don't exist in this hbase. +<%else> +<%java> + Thread changetd = new ChangePriorityThread(admin, tablename, tablepri, + scanpri, putpri, getpri, delpri); + changetd.setName("cahngetd"); + changetd.start(); + + + + + \ No newline at end of file diff -uNr src/org/apache/hbase/tmpl/table/tablepriority.jamon src/org/apache/hbase/tmpl/table/tablepriority.jamon --- src/org/apache/hbase/tmpl/table/tablepriority.jamon (revision 0) +++ src/org/apache/hbase/tmpl/table/tablepriority.jamon (working copy) @@ -0,0 +1,130 @@ +<%doc> +Copyright 2011 The Apache Software Foundation + +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +<%import> +import="org.apache.hadoop.conf.Configuration" +import="org.apache.hadoop.hbase.HBaseConfiguration" +import="org.apache.hadoop.hbase.HTableDescriptor" +import="org.apache.hadoop.hbase.MasterNotRunningException" +import="org.apache.hadoop.hbase.ZooKeeperConnectionException" +import="org.apache.hadoop.hbase.master.HMaster" +import="org.apache.hadoop.hbase.client.HBaseAdmin" +import="org.apache.hadoop.hbase.ipc.PriorityHBaseServer" +import="org.apache.hadoop.hbase.ipc.PriorityFunction" +import="org.apache.hadoop.hbase.ipc.PriorityJobQueue" +import="org.apache.hadoop.hbase.util.Bytes" + +<%java> + HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER); + HBaseAdmin admin = null; + HTableDescriptor[] tables = null; + try { + admin = new HBaseAdmin(master.getConfiguration()); + tables = admin.listTables(); + } catch (Exception e) { + out.println("Can't connect hbase ,check carefullt!"); + return; + } + + + + + +Table Priority + + + + + + +

Table Priority

+ +
+ +

Table priority

+<%if tables.length <= 0 %> +No tables in hbase. +<%java> + return; + +<%else> + + + ; + ; + + + + + + + <%for HTableDescriptor table : tables %> + + <%if !admin.isTableEnabled(table.getName()) %> + + <%java> + continue; + + <%else> + <%java + String tablepri = Bytes.toString(table.getValue(PriorityFunction.PRI_KEY)); + + <%if (tablepri == null || tablepri.length() <= 0) %> + <%java> + tablepri = new Integer(PriorityFunction.DEFAULT_PRI).toString(); + + <%if> + + <%java> + PriorityJobQueue.ActionPriorities action = PriorityFunction.getTableActionPriorities(table); + + ; + "; + + + + + "); + + + + + + + + + + + + +
Show Table Priority +
TablenamePriorityScanPutGetDeleteChange
<% table.getNameAsString() %> Waiting Change...
<% tablepri %><% action.getScanPlus() %><% action.getPutPlus() %><% action.getGetPlus() %><% action.getDeletePlus() %>
+ + + \ No newline at end of file