accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [22/54] [partial] ACCUMULO-658, ACCUMULO-656 Split server into separate modules
Date Fri, 01 Nov 2013 00:56:01 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/main/resources/web/functions.js
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/resources/web/functions.js b/server/monitor/src/main/resources/web/functions.js
new file mode 100644
index 0000000..f4bbdd1
--- /dev/null
+++ b/server/monitor/src/main/resources/web/functions.js
@@ -0,0 +1,21 @@
+/*
+* 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.
+*/
+function toggle(selection) {
+  var p = document.getElementById(selection);
+  var style = p.className;
+  p.className = style == "hide" ? "show" : "hide";
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/main/resources/web/screen.css
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/resources/web/screen.css b/server/monitor/src/main/resources/web/screen.css
new file mode 100644
index 0000000..7aa49a0
--- /dev/null
+++ b/server/monitor/src/main/resources/web/screen.css
@@ -0,0 +1,392 @@
+/*
+* 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.
+*/
+/* basic screen style for all pages */
+html,body {
+	height: 100%;
+	margin: 0;
+	padding: 0;
+	color: #333333;
+	font-size: 10pt;
+	font-family: verdana, arial, sans-serif;
+	text-align: center;
+}
+
+#content-wrapper {
+	position: relative;
+	min-height: 100%;
+}
+
+* #content-wrapper {
+	height: 100%;
+}
+
+#content {
+	position: absolute;
+	left: 0;
+	right: 0;
+	top: 0;
+	bottom: 0;
+	padding-bottom: 0;
+}
+
+#header {
+	position: absolute;
+	padding-top: 0;
+	top: 0;
+	left: 0;
+	right: 0;
+	height: 8.0em;
+	color: #c4c4c4;
+	background-color: #304065;
+	text-align: center;
+}
+
+#banner {
+	height: 1.5em;
+	font-size: 1.0em;
+}
+
+#headertitle {
+	position: absolute;
+	top: 0;
+	left: 0;
+	right: 0;
+}
+
+#subheader {
+	position: absolute;
+	bottom: 0;
+	left: 0;
+	right: 0;
+	font-size: .92em;
+}
+
+#footer {
+	position: absolute;
+	bottom: 0;
+	left: 0;
+	right: 0;
+	padding: 0;
+	height: 1.5em;
+	font-size: 1.0em;
+}
+
+#main {
+	position: absolute;
+	top: 8.0em;
+	left: 11em;
+	right: 0;
+	bottom: 1.5em;
+	padding: 0.6em;
+	overflow: scroll;
+}
+
+#nav {
+	position: absolute;
+	top: 8.0em;
+	left: 0;
+	bottom: 0;
+	padding: 0.5em;
+	width: 10em;
+	color: #304065;
+	background-color: #c4c4c4;
+	text-align: left;
+}
+
+#nav-title {
+	margin-left: auto;
+	margin-right: auto;
+	text-align: center;
+	font-size: 1.1em;
+}
+
+h1 {
+	font-size: 2.2em;
+	font-variant: small-caps;
+	text-align: center;
+}
+
+h2 {
+	width: 100%;
+	font-size: 1.3em;
+	text-align: center;
+}
+
+h2.error {
+	width: 100%;
+	color: #ff0000;
+	background-color: #000000;
+}
+
+h2.error a {
+	color: #ff0000;
+	background-color: #000000;
+}
+
+caption {
+	margin-left: auto;
+	margin-right: auto;
+}
+
+caption.error {
+	color: #ff0000;
+	background-color: #000000;
+}
+
+hr {
+	border: 0;
+	height: 1px;
+	background-color: #304065;
+	color: #304065;
+}
+
+table {
+	margin-left: auto;
+	margin-right: auto;
+	min-width: 60%;
+	border: 1px #333333 solid;
+	border-spacing-top: 0;
+	border-spacing-bottom: 0;
+	font-size: 9pt;
+	border: 1px #333333 solid;
+	border: 1px #333333 solid;
+}
+
+/*
+The following is to avoid a problem with the flot
+javascript library.  This file sets min-width to 60% 
+for all tables.  This make the html generated by
+flot.js not work.  Flot creates a class called legend
+used in a div that has a child table.  This sets 
+min-width to 0 for that child table enabling it
+to render correctly.  
+*/
+div.legend > table {
+        min-width: 0%;
+}
+
+table.sortable {
+	border-left: 0;
+	border-right: 0;
+	border-top: 1px #333333 dotted;
+	border-bottom: 1px #333333 dotted;
+}
+
+td {
+	border-top: 0;
+	border-bottom: 0;
+	border-left: 0;
+	border-right: 0;
+	border-spacing-top: 0;
+	border-spacing-bottom: 0;
+	padding-left: 0.5em;
+	padding-right: 0.5em;
+	padding-top: 0.15em;
+	padding-bottom: 0.15em;
+	color: #333333;
+}
+
+th {
+	border-top: 0;
+	border-bottom: 3px #333333 solid;
+	border-left: 1px #333333 dotted;
+	border-right: 0;
+	border-spacing-top: 0;
+	border-spacing-bottom: 0;
+	text-align: center;
+	font-variant: small-caps;
+	padding-left: 0.5em;
+	padding-right: 0.5em;
+	padding-top: 0.2em;
+	padding-bottom: 0.2em;
+	color: #333333;
+	font-size: 10pt;
+	vertical-align: bottom;
+}
+
+td.firstcell {
+	border-left: 0;
+}
+
+th.firstcell {
+	border-left: 0;
+}
+
+a {
+	text-decoration: none;
+	color: #0000ff;
+	line-height: 1.5em;
+}
+
+a:hover {
+	color: #004400;
+	text-decoration: underline;
+}
+
+a img {
+	border: 0px;
+}
+
+div.show {
+	display: block;
+}
+
+div.hide {
+	display: none;
+}
+
+div.progress-chart {
+	border: 1px solid #333333;
+	border-spacing: 0;
+	width: 150px;
+	float: left;
+}
+
+div.progress-chart>div {
+	height: 20px;
+	background-color: #0000ff;
+}
+
+pre.logevent {
+	margin: 0;
+}
+
+.noborder {
+	border: 0;
+	border-spacing: 0;
+	border-bottom: 0;
+	border-right: 0;
+}
+
+.noborder td {
+	vertical-align: top;
+}
+
+.table-caption {
+	font-size: 2em;
+	font-variant: small-caps;
+	text-align: center;
+}
+
+.table-subcaption {
+	font-size: 0.9em;
+}
+
+.left {
+	text-align: left;
+}
+
+.right {
+	text-align: right;
+	margin-right: 0;
+}
+
+.error {
+	color: #ffffff;
+	background-color: #ff0000;
+}
+
+.error a {
+	color: #ffffff;
+	background-color: #ff0000;
+}
+
+.warning {
+	background-color: #ffff33;
+}
+
+.warning a {
+	background-color: #ffff33;
+}
+
+.highlight {
+	background-color: #cef4b5;
+}
+
+.smalltext {
+	font-size: 0.8em;
+}
+
+.center {
+	text-align: center;
+	padding: 0.5em;
+}
+
+.plotHeading {
+    text-align: center;
+    font-size: 1.5em;
+}
+.nowrap {
+    white-space:nowrap;
+}
+
+.viscontrol {
+    border: 1px solid #c4c4c4;
+    padding: 5px;
+}
+
+#vishoverinfo {
+    visibility: hidden;
+    position: absolute;
+    border: 1px solid #c4c4c4;
+    background-color: #ffffff;
+}
+
+#shell {
+    text-align: left;
+    color: #55d839;
+    border: 1px;
+    padding-left: 5px;
+    background-color: #000000;
+    height: 40em;
+    overflow: auto;
+    font-family: Monaco, monospace;
+    font-size: 100%;
+}
+
+#shell span {
+    display: inline;
+}
+
+#shell input {
+    display: inline;
+    border: none;
+    width: 60%;
+    color: #55d839;
+    background-color: #000000;
+    font-family: Monaco, monospace;
+    font-size: 100%;
+}
+
+#shell pre {
+    font-family: Monaco, monospace;
+    font-size: 100%;
+}
+
+#login {
+    text-align: left;
+}
+
+#login table {
+    margin-left: 0;
+    min-width: 0%;
+}
+
+#loginError {
+    text-align: left;
+    color: red;
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/main/resources/web/up.gif
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/resources/web/up.gif b/server/monitor/src/main/resources/web/up.gif
new file mode 100644
index 0000000..b272cbb
Binary files /dev/null and b/server/monitor/src/main/resources/web/up.gif differ

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/main/resources/web/vis.js
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/resources/web/vis.js b/server/monitor/src/main/resources/web/vis.js
new file mode 100644
index 0000000..c0f8b3f
--- /dev/null
+++ b/server/monitor/src/main/resources/web/vis.js
@@ -0,0 +1,409 @@
+/*
+ * 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.
+ */
+ 
+// size and spacing variables
+var dotSpacing = 10; // spacing between centers of dots (radius)
+var dotPadding = 0.5; // dot padding
+var minDotRadius = 3; // min dot radius
+var maxDotRadius = dotSpacing - dotPadding;
+
+// arrays of information about each dot
+var stats = {'servers': []};
+var dots = new Array(0); // current sizes and change directions
+var mousedDot = -1; // the dot currently under the mouse
+
+var colorPalette = ['#0000CC', '#0014B8', '#0029A3', '#003D8F', '#00527A', '#006666', '#007A52', '#008F3D', '#00A329', '#00B814', '#00CC00', '#14D100', '#29D600', '#3DDB00', '#52E000', '#66E600', '#7AEB00', '#8FF000', '#A3F500', '#B8FA00', '#CCFF00', '#CCFF00', '#CCF200', '#CCE600', '#CCD900', '#CCCC00', '#CCBF00', '#CCB200', '#CCA600', '#CC9900', '#CC8C00', '#CC8000', '#CC7300', '#CC6600', '#CC5900', '#CC4C00', '#CC4000', '#CC3300', '#CC2600', '#CC1A00', '#CC0D00', '#CC0000'];
+
+var nullColor = '#F5F8FA';
+var deadColor = '#B000CC';
+
+// animation variables
+var drawing = false;
+var canvas = document.getElementById('visCanvas');
+var context = canvas.getContext('2d');
+
+// mouse handling for server information display
+document.getElementById('hoverable').addEventListener('mouseover', showId, false);
+document.getElementById('hoverable').addEventListener('mousemove', showId, false);
+document.getElementById('hoverable').addEventListener('mouseout', hideId, false);
+document.getElementById('vishoverinfo').addEventListener('click', goToServer, false);
+canvas.addEventListener('click', goToServer, false);
+
+// initialize settings based on request parameters
+var main = document.getElementById('main');
+var speedStatType;
+var colorStatType;
+var speedDisabled = true;
+var useCircles = true;
+setShape(document.getElementById('shape'));
+setSize(document.getElementById('size'));
+setMotion(document.getElementById('motion'));
+setColor(document.getElementById('color'));
+
+// xml loading variables
+var xmlReturned = true;
+var xmlhttp=new XMLHttpRequest(); // don't bother allowing for IE 5 or 6 since canvas won't work
+xmlhttp.onreadystatechange=function() {
+  handleNewData();
+}
+self.setInterval("getXML()",5000);
+//self.setInterval("drawDots()",20);
+
+window.requestAnimFrame = (function(callback){
+  return window.requestAnimationFrame ||
+  window.webkitRequestAnimationFrame ||
+  window.mozRequestAnimationFrame ||
+  window.oRequestAnimationFrame ||
+  window.msRequestAnimationFrame ||
+  function(callback){
+    window.setTimeout(callback, 1000 / 60);
+  };
+})();
+
+function handleNewData() {
+  if (xmlhttp.readyState!=4) {
+    return;
+  }
+  if (xmlhttp.status!=200 || xmlhttp.responseText==null) {
+    xmlReturned = true;
+    return;
+  }
+  var newstats = eval('(' + xmlhttp.responseText + ')');
+  for (var i in newstats.servers) {
+    for (var s in statNames) {
+      if (statNames[s])
+        continue;
+      newstats.servers[i][s] = Math.max(0,Math.floor(significance[s]*newstats.servers[i][s])/significance[s]);
+      if (adjustMax[s])
+        maxStatValues[s] = Math.max(newstats.servers[i][s],maxStatValues[s]);
+    }
+  }
+  
+  initDerivedInfo(newstats);
+  var oldstats = stats;
+  while(drawing) {}
+  stats = newstats;
+  delete oldstats;
+  xmlReturned = true;
+}
+
+// set max and average
+function setDerivedStats(serverStats) {
+  var avgStat = 0;
+  var maxStat = 0;
+  var maxIndex = 0;
+  for (var s in statNames) {
+    if (statNames[s])
+      continue;
+    normStat = serverStats[s]/maxStatValues[s];
+    if (normStat > 0)
+      avgStat += normStat;
+    if (maxStat < normStat) {
+      maxStat = normStat;
+      maxIndex = s;
+    }
+  }
+  serverStats.allmax = Math.floor(significance.allmax*Math.min(1,maxStat))/significance.allmax;
+  serverStats.allavg = Math.floor(significance.allavg*avgStat/numNormalStats)/significance.allavg;
+  serverStats.maxStat = maxIndex;
+}
+
+function initDerivedInfo(newstats) {
+  for (var i in newstats.servers) {
+    if ('dead' in newstats.servers[i] || 'bad' in newstats.servers[i]) {
+      continue;
+    }
+    if (i >= dots.length) {
+      dots.push({'size': maxDotRadius, 'growing': false});
+    }
+    setDerivedStats(newstats.servers[i]);
+  }
+}
+
+// construct server info for hover
+function getInfo(serverStats) {
+  var extra = '<strong>' + serverStats.ip + '</strong>';
+  if ('dead' in serverStats || 'bad' in serverStats)
+    return extra;
+  extra = extra + ' (' + serverStats.hostname + ')';
+  var j = 0;
+  for (var s in statNames) {
+    if (j % 4 == 0)
+      extra = extra + '<br>\n';
+    extra = extra + '&nbsp;&nbsp;' + s + ': <strong>' + serverStats[s] + '</strong>';
+    j++;
+  }
+  extra = extra + ' (' + serverStats.maxStat + ')';
+  return extra;
+}
+
+// reload xml
+function getXML() {
+  if (xmlReturned == true) {
+    xmlReturned = false;
+    xmlhttp.open('POST',jsonurl,true);
+    xmlhttp.send();
+  }
+}
+
+// redraw
+function drawDots() {
+  requestAnimFrame(drawDots);
+  
+  var width = Math.ceil(Math.sqrt(stats.servers.length));
+  var height = Math.ceil(stats.servers.length/width);
+  var x;
+  var y;
+  var server
+  var sizeChange;
+  drawing = true;
+  for (var i in stats.servers) {
+    server = stats.servers[i];
+    x = i % width;
+    y = Math.floor(i / width);
+    if ('bad' in server || 'dead' in server) {
+      strokeDot(x,y,maxDotRadius-1,deadColor);
+      continue;
+    }
+    if (speedDisabled || Math.floor(dots[i].size) > maxDotRadius) {
+      // check for resize by the user
+      dots[i].size = maxDotRadius;
+    } else if (server[speedStatType]<=0) {
+      // if not changing size, increase to max radius
+      if (dots[i].size < maxDotRadius)
+        dots[i].size = dots[i].size + 1;
+      if (dots[i].size > maxDotRadius)
+        dots[i].size = maxDotRadius;
+    } else {
+      sizeChange = getStat(i,speedStatType);
+      if (dots[i].growing) {
+        dots[i].size = dots[i].size + sizeChange;
+        if (dots[i].size + sizeChange > maxDotRadius) {
+          dots[i].growing = false;
+        }
+      }
+      else {
+        dots[i].size = dots[i].size - sizeChange;
+        if (dots[i].size - sizeChange < minDotRadius) {
+          dots[i].growing = true;
+        }
+      }
+    }
+    drawDot(x,y,Math.floor(dots[i].size),getColor(getStat(i,colorStatType)));
+  }
+  // mousedDot shouldn't be set to an invalid dot, but stats might have changed since then
+  if (mousedDot >= 0 && mousedDot < stats.servers.length)
+    document.getElementById('vishoverinfo').innerHTML=getInfo(stats.servers[mousedDot]);
+  drawing = false;
+}
+
+// fill in a few grey dots
+function drawGrid() {
+  context.clearRect(0, 0, canvas.width, canvas.height);
+  for (var i=0, k=0; i < canvas.width; i+=dotSpacing*2,k++) {
+    for (var j=0, l=0; j < canvas.height; j+=dotSpacing*2,l++) {
+      drawDot(k,l,maxDotRadius,nullColor);
+    }
+  }
+}
+
+// fill a dot specified by indices into dot grid
+function drawDot(i,j,r,c) {
+  var x = i*dotSpacing*2 + dotSpacing;
+  var y = j*dotSpacing*2 + dotSpacing;
+  context.clearRect(x-dotSpacing, y-dotSpacing, dotSpacing*2, dotSpacing*2);
+  if (useCircles)
+    fillCircle(x,y,r-dotPadding,c);
+  else
+    fillSquare(x-r,y-r,(r-dotPadding)*2,c);
+}
+
+// stroke a dot specified by indices into dot grid
+function strokeDot(i,j,r,c) {
+  var x = i*dotSpacing*2 + dotSpacing;
+  var y = j*dotSpacing*2 + dotSpacing;
+  context.clearRect(x-dotSpacing, y-dotSpacing, dotSpacing*2, dotSpacing*2);
+  if (useCircles)
+    strokeCircle(x,y,r-dotPadding,c);
+  else
+    strokeSquare(x-r,y-r,(r-dotPadding)*2,c);
+}
+
+function getStat(dotIndex,statIndex) {
+  return Math.min(1,stats.servers[dotIndex][statIndex]/maxStatValues[statIndex]);
+}
+
+// translate color between 0 and maxObservedColor into an html color code
+function getColor(normColor) {
+  return colorPalette[Math.round((colorPalette.length-1)*normColor)];
+}
+
+function strokeCircle(x,y,r,c) {
+  context.strokeStyle = c;
+  context.lineWidth = 2;
+  context.beginPath();
+  context.arc(x,y,r,0,Math.PI*2,true);
+  context.closePath();
+  context.stroke();
+}
+
+function fillCircle(x,y,r,c) {
+  context.fillStyle = c;
+  context.beginPath();
+  context.arc(x,y,r,0,Math.PI*2,true);
+  context.closePath();
+  context.fill();
+}
+
+function strokeSquare(x,y,d,c) {
+  context.strokeStyle = c;
+  context.lineWidth = 2;
+  context.strokeRect(x,y,d,d);
+}
+
+function fillSquare(x,y,d,c) {
+  context.fillStyle = c;
+  context.fillRect(x,y,d,d);
+}
+
+// callback for shape selection
+function setShape(obj) {
+  switch (obj.selectedIndex) {
+    case 0:
+      useCircles = true;
+      break;
+    case 1:
+      useCircles = false;
+      break;
+    default:
+      useCircles = true;
+  }
+  drawGrid();
+  setState();
+}
+
+// callback for size selection
+function setSize(obj) {
+  switch (obj.selectedIndex) {
+    case 0:
+      dotSpacing = 5;
+      minDotRadius = 1;
+      break;
+    case 1:
+      dotSpacing = 10;
+      minDotRadius = 3;
+      break;
+    case 2:
+      dotSpacing = 20;
+      minDotRadius = 5;
+      break;
+    case 3:
+      dotSpacing = 40;
+      minDotRadius = 7;
+      break;
+    default:
+      dotSpacing = 10;
+      minDotRadius = 3;
+  }
+  maxDotRadius = dotSpacing - dotPadding;
+  drawGrid();
+  setState();
+}
+
+// callback for motion selection
+function setMotion(obj) {
+  if (obj.selectedIndex==0) {
+    speedDisabled = true;
+    setState();
+    return;
+  }
+  var i = 1;
+  for (var s in statNames) {
+    if (i==obj.selectedIndex) {
+      speedStatType = s;
+      break;
+    }
+    i++;
+  }
+  speedDisabled = false;
+  setState();
+}
+
+// callback for color selection
+function setColor(obj) {
+  var i = 0;
+  for (var s in statNames) {
+    if (i==obj.selectedIndex) {
+      colorStatType = s;
+      break;
+    }
+    i++;
+  }
+  setState();
+}
+
+// hide server info on mouseout
+function hideId(e) {
+  document.getElementById('vishoverinfo').style.visibility='hidden';
+}
+
+// display server info on mouseover
+function showId(e) {
+  var x;
+  var y;
+  if (e.pageX || e.pageY) {
+    x = e.pageX + main.scrollLeft;
+    y = e.pageY + main.scrollTop;
+  }
+  else {
+    // clientX and clientY unimplemented
+    return;
+  }
+  var relx = x - canvas.offsetLeft - main.offsetLeft;
+  var rely = y - canvas.offsetTop - main.offsetTop;
+  var width = Math.ceil(Math.sqrt(stats.servers.length));
+  gotDot = Math.floor(relx/(dotSpacing*2)) + width*Math.floor(rely/(dotSpacing*2));
+  mousedDot = -1;
+  if (relx < (width*dotSpacing*2) && gotDot >= 0 && gotDot < stats.servers.length) {
+    mousedDot = gotDot;
+    document.getElementById('vishoverinfo').style.left=relx+canvas.offsetLeft;
+    document.getElementById('vishoverinfo').style.top=Math.max(0,rely+canvas.offsetTop-70);
+    document.getElementById('vishoverinfo').style.visibility='visible';
+  }
+  else {
+    document.getElementById('vishoverinfo').style.visibility='hidden';
+  }
+}
+
+function setState() {
+  var url = visurl+'?shape='+(useCircles?'circles':'squares')+'&size='+(dotSpacing*2)+(speedDisabled ? '' : '&motion='+speedStatType)+'&color='+colorStatType;
+  window.history.replaceState(window.history.state,'Server Activity',url);
+}
+
+// go to server page on click
+function goToServer(e) {
+  // mousedDot shouldn't be set to an invalid dot, but stats might have changed since then
+  if (mousedDot >= 0 && mousedDot < stats.servers.length)
+    window.location = serverurl + stats.servers[mousedDot].ip;
+}
+
+window.onload = function() {
+  drawGrid();
+  drawDots();
+  getXML();
+}
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java b/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java
new file mode 100644
index 0000000..a630434
--- /dev/null
+++ b/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+package org.apache.accumulo.monitor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.accumulo.trace.thrift.RemoteSpan;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ShowTraceLinkTypeTest {
+  
+  @Test
+  public void testTraceSortingForMonitor() {
+    /*
+     * public RemoteSpan(String sender, String svc, long traceId, long spanId, long parentId, long start, long stop, String description, Map<String,String>
+     * data)
+     */
+    ArrayList<RemoteSpan> spans = new ArrayList<RemoteSpan>(10), expectedOrdering = new ArrayList<RemoteSpan>(10);
+    
+    // "Random" ordering
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 55l, 75l, "desc5", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 25l, 30l, "desc2", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 85l, 90l, "desc8", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 45l, 60l, "desc4", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 35l, 55l, "desc3", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 95l, 110l, "desc9", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 65l, 80l, "desc6", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 100l, 120l, "desc10", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 15l, 25l, "desc1", Collections.<String,String> emptyMap()));
+    spans.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 75l, 100l, "desc7", Collections.<String,String> emptyMap()));
+    
+    // We expect them to be sorted by 'start'
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 15l, 25l, "desc1", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 25l, 30l, "desc2", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 35l, 55l, "desc3", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 45l, 60l, "desc4", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 55l, 75l, "desc5", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 65l, 80l, "desc6", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 75l, 100l, "desc7", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 85l, 90l, "desc8", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 95l, 110l, "desc9", Collections.<String,String> emptyMap()));
+    expectedOrdering.add(new RemoteSpan("sender", "svc", 0l, 0l, 0l, 100l, 120l, "desc10", Collections.<String,String> emptyMap()));
+    
+    Collections.sort(spans);
+    
+    Assert.assertEquals(expectedOrdering, spans);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/monitor/src/test/java/org/apache/accumulo/monitor/ZooKeeperStatusTest.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/test/java/org/apache/accumulo/monitor/ZooKeeperStatusTest.java b/server/monitor/src/test/java/org/apache/accumulo/monitor/ZooKeeperStatusTest.java
new file mode 100644
index 0000000..a90396b
--- /dev/null
+++ b/server/monitor/src/test/java/org/apache/accumulo/monitor/ZooKeeperStatusTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.accumulo.monitor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.accumulo.monitor.ZooKeeperStatus.ZooKeeperState;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ZooKeeperStatusTest {
+  
+  @Test
+  public void zkHostSortingTest() {
+    List<String> expectedHosts = Arrays.asList("rack1node1", "rack2node1", "rack4node1", "rack4node4");
+    
+    // Add the states in a not correctly sorted order
+    TreeSet<ZooKeeperState> states = new TreeSet<ZooKeeperState>();
+    states.add(new ZooKeeperState("rack4node4", "leader", 10));
+    states.add(new ZooKeeperState("rack4node1", "follower", 10));
+    states.add(new ZooKeeperState("rack1node1", "follower", 10));
+    states.add(new ZooKeeperState("rack2node1", "follower", 10));
+    
+    List<String> actualHosts = new ArrayList<String>(4);
+    for (ZooKeeperState state : states) {
+      actualHosts.add(state.keeper);
+    }
+    
+    // Assert we have 4 of each
+    Assert.assertEquals(expectedHosts.size(), actualHosts.size());
+    
+    // Assert the ordering is correct
+    for (int i = 0; i < expectedHosts.size(); i++) {
+      Assert.assertEquals(expectedHosts.get(i), actualHosts.get(i));
+    }
+    
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/pom.xml
----------------------------------------------------------------------
diff --git a/server/native/pom.xml b/server/native/pom.xml
new file mode 100644
index 0000000..1ec4d9d
--- /dev/null
+++ b/server/native/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.accumulo</groupId>
+    <artifactId>accumulo-project</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <artifactId>accumulo-native</artifactId>
+  <packaging>pom</packaging>
+  <name>Native Libraries</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-tserver</artifactId>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>native-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-javah-includes</id>
+            <goals>
+              <goal>javah</goal>
+            </goals>
+            <phase>compile</phase>
+            <configuration>
+              <javahClassNames>
+                <javahClassName>org.apache.accumulo.tserver.NativeMap</javahClassName>
+              </javahClassNames>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>assemble-native-tarball</id>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <attach>true</attach>
+              <appendAssemblyId>false</appendAssemblyId>
+              <descriptors>
+                <descriptor>src/main/assemblies/native-tarball.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/assemblies/component.xml
----------------------------------------------------------------------
diff --git a/server/native/src/main/assemblies/component.xml b/server/native/src/main/assemblies/component.xml
new file mode 100644
index 0000000..3f2f993
--- /dev/null
+++ b/server/native/src/main/assemblies/component.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 http://maven.apache.org/xsd/component-1.1.2.xsd">
+  <fileSets>
+    <fileSet>
+      <directory>src/main/c++/nativeMap</directory>
+      <outputDirectory>nativeMap</outputDirectory>
+      <directoryMode>0755</directoryMode>
+      <fileMode>0644</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>src/main/resources</directory>
+      <outputDirectory>.</outputDirectory>
+      <directoryMode>0755</directoryMode>
+      <fileMode>0644</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>${project.build.directory}/native/javah</directory>
+      <outputDirectory>javah</outputDirectory>
+      <directoryMode>0755</directoryMode>
+      <fileMode>0644</fileMode>
+    </fileSet>
+  </fileSets>
+</component>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/assemblies/native-tarball.xml
----------------------------------------------------------------------
diff --git a/server/native/src/main/assemblies/native-tarball.xml b/server/native/src/main/assemblies/native-tarball.xml
new file mode 100644
index 0000000..1d1480b
--- /dev/null
+++ b/server/native/src/main/assemblies/native-tarball.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>src</id>
+  <formats>
+    <format>dir</format>
+    <format>tar.gz</format>
+  </formats>
+  <componentDescriptors>
+    <componentDescriptor>src/main/assemblies/component.xml</componentDescriptor>
+  </componentDescriptors>
+</assembly>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/BlockAllocator.h
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/BlockAllocator.h b/server/native/src/main/c++/nativeMap/BlockAllocator.h
new file mode 100644
index 0000000..d62ffd5
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/BlockAllocator.h
@@ -0,0 +1,268 @@
+/*
+* 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.
+*/
+
+
+#ifndef _BLOCK_ALLOCATOR_H_
+#define _BLOCK_ALLOCATOR_H_ 1
+
+#include <new>
+#include <bits/functexcept.h>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <stdlib.h>
+#include <stddef.h>
+
+struct Block {
+	unsigned char *data;
+	unsigned char *currentPos;
+	unsigned char *end;
+	unsigned char *prevPos;
+
+	Block(uint32_t size){
+		data = new unsigned char[size];
+		end = data + size;
+		currentPos = data;
+		prevPos = NULL;
+	}
+	
+	~Block(){
+	}
+
+	void *allocate(size_t amount){
+		unsigned char *nextPos = currentPos + amount;
+		
+		if(nextPos > end){
+			return NULL;
+		}
+
+		prevPos = currentPos;
+		currentPos = nextPos;
+		return prevPos;
+	}
+
+	size_t rollback(void *p){
+		if(p == prevPos){
+			size_t diff = currentPos - prevPos;
+			currentPos = prevPos;
+			return diff;
+		}else{
+			std::cerr << "Tried to delete something that was not previous allocation " << p << " " << prevPos << std::endl;
+			exit(-1);
+		}
+
+		return 0;
+	}
+
+        size_t getMemoryFree() {
+	        return end - currentPos;
+        }
+};
+
+struct BigBlock {
+	unsigned char *ptr;
+	size_t length;
+
+	BigBlock(unsigned char *p, size_t len):ptr(p),length(len){}
+};
+
+struct LinkedBlockAllocator {
+
+	std::vector<Block> blocks;
+	std::vector<BigBlock> bigBlocks;
+	int blockSize;
+	int bigBlockSize;
+	int64_t memused;
+	void *lastAlloc;
+
+	LinkedBlockAllocator(int blockSize, int bigBlockSize){
+		this->blockSize = blockSize;
+		this->bigBlockSize = bigBlockSize;
+		lastAlloc = NULL;
+		memused = 0;
+	}
+	
+	void *allocate(size_t amount){
+
+	        if(amount > (size_t)bigBlockSize){
+			unsigned char *p = new unsigned char[amount];
+			bigBlocks.push_back(BigBlock(p, amount));
+			memused += sizeof(BigBlock) + amount;
+			return p;
+		}else{
+			if(blocks.size() == 0){
+				//do lazy allocation of memory, do not allocate a block until it is used
+				blocks.push_back(Block(blockSize));
+				memused += sizeof(Block) + blockSize;
+			}
+
+			lastAlloc = blocks.back().allocate(amount);
+			if(lastAlloc == NULL){
+				blocks.push_back(Block(blockSize));
+				lastAlloc = blocks.back().allocate(amount);
+				memused += sizeof(Block) + blockSize;
+			}
+
+			return lastAlloc;
+		}
+	}
+
+	void deleteLast(void *p){
+		if(p != NULL){
+			if(p == lastAlloc){
+				blocks.back().rollback(p);
+				lastAlloc = NULL;
+				return;
+			}else if(bigBlocks.back().ptr == p){
+				memused -= (sizeof(BigBlock) + bigBlocks.back().length);
+				bigBlocks.pop_back();
+				delete((unsigned char *)p);
+				return;
+			}
+		}
+
+		std::cerr << "Tried to delete something that was not last allocation " << p << " " << lastAlloc << std::endl;
+		exit(-1);
+	}	
+
+	size_t getMemoryUsed(){
+		if(blocks.size() == 0)
+			return memused;
+		else
+		        return memused - blocks.back().getMemoryFree();
+	}
+	
+	~LinkedBlockAllocator(){
+		//std::cout << "Deleting " << blocks.size() << " blocks, memused : " << memused << std::endl;
+		std::vector<Block>::iterator iter = blocks.begin();
+		while(iter != blocks.end()){
+		  	delete [] (iter->data);
+			iter++;
+		}
+
+		std::vector<BigBlock>::iterator iter2 = bigBlocks.begin();
+		while(iter2 != bigBlocks.end()){
+		  	delete [] (iter2->ptr);
+			iter2++;
+		}
+	}
+		
+};
+
+
+  /**
+   *  @brief  An allocator that uses global new, as per [20.4].
+   *
+   *  This is precisely the allocator defined in the C++ Standard. 
+   *    - all allocation calls operator new
+   *    - all deallocation calls operator delete
+   */
+  template<typename _Tp>
+    class BlockAllocator
+    {
+    public:
+      typedef size_t     size_type;
+      typedef ptrdiff_t  difference_type;
+      typedef _Tp*       pointer;
+      typedef const _Tp* const_pointer;
+      typedef _Tp&       reference;
+      typedef const _Tp& const_reference;
+      typedef _Tp        value_type;
+
+      LinkedBlockAllocator *lba;
+
+      template<typename _Tp1>
+        struct rebind
+        { typedef BlockAllocator<_Tp1> other; };
+
+      BlockAllocator() throw() {
+        lba = NULL;
+      }
+
+      BlockAllocator(LinkedBlockAllocator *lba) throw() {
+        this->lba = lba; 
+      }
+
+      BlockAllocator(const BlockAllocator& ba) throw() {
+        lba = ba.lba;
+      }
+
+      template<typename _Tp1>
+        BlockAllocator(const BlockAllocator<_Tp1>& ba) throw() { 
+          lba = ba.lba;
+        }
+
+      ~BlockAllocator() throw() { }
+
+      pointer
+      address(reference __x) const { return &__x; }
+
+      const_pointer
+      address(const_reference __x) const { return &__x; }
+
+      // NB: __n is permitted to be 0.  The C++ standard says nothing
+      // about what the return value is when __n == 0.
+      pointer
+      allocate(size_type __n, const void* = 0)
+      { 
+	if (__builtin_expect(__n > this->max_size(), false))
+	  std::__throw_bad_alloc();
+
+
+	//void *p = ::operator new(__n * sizeof(_Tp));
+	void *p = lba->allocate(__n * sizeof(_Tp));
+
+	//std::cout << "Allocating "<< name <<" " << __n * sizeof(_Tp) << " "  << ((unsigned long long)p) % 4 << " " << ((unsigned long long)p) % 8 << std::endl;
+
+	return static_cast<_Tp*>(p);
+      }
+
+      // __p is not permitted to be a null pointer.
+      void
+      deallocate(pointer __p, size_type)
+      { 
+        //::operator delete(__p);
+      } 
+
+      size_type
+      max_size() const throw() 
+      { return size_t(-1) / sizeof(_Tp); }
+
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 402. wrong new expression in [some_] allocator::construct
+      void 
+      construct(pointer __p, const _Tp& __val) 
+      { ::new(__p) _Tp(__val); }
+
+      void 
+      destroy(pointer __p) { __p->~_Tp(); }
+     
+ 
+    };
+
+
+  template<typename _Tp>
+    inline bool
+    operator==(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
+    { return true; }
+  
+  template<typename _Tp>
+    inline bool
+    operator!=(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
+    { return false; }
+
+#endif

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/Field.h
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/Field.h b/server/native/src/main/c++/nativeMap/Field.h
new file mode 100644
index 0000000..7c3884e
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/Field.h
@@ -0,0 +1,143 @@
+/*
+* 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.
+*/
+#include <stdint.h>
+#include <string.h>
+#include <jni.h>
+#include <string>
+#include <string.h>
+#include <iostream>
+#include <stdlib.h>
+#include "BlockAllocator.h"
+
+using namespace std;
+
+#ifndef __FIELD__
+#define __FIELD__
+
+struct Field {
+	uint8_t *field;
+	int32_t len;
+
+ 	int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+		int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
+		
+		if(result != 0)
+			return result;
+		if(len1 == len2)
+			return 0;
+		if(len1 < len2)
+			return -1;
+
+		return 1;
+	}
+
+	Field(){}
+
+	Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f, int l){
+		len = l;
+		field=(uint8_t *)lba->allocate(len);
+		env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+	}
+
+	Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f){
+		len = env->GetArrayLength(f);
+		field=(uint8_t *)lba->allocate(len);
+		env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+	}
+	
+	Field(uint8_t *f, int32_t l):field(f),len(l){
+ 	}
+
+	Field(const char *cstr){
+		//constructor for testing C++
+		len = strlen(cstr);
+		field=new uint8_t[len];
+		memcpy(field, cstr, len);
+	}
+
+	Field(LinkedBlockAllocator *lba, const char *cstr){
+		//constructor for testing C++
+		len = strlen(cstr);
+		field=(uint8_t *)lba->allocate(len);
+		memcpy(field, cstr, len);
+	}
+
+	void set(const char *d, int l){
+		if(l < 0 || l > len){
+			cerr << "Tried to set field with value that is too long " << l << " " << len << endl;	
+		}
+		memcpy(field, d, l);
+		len = l;
+	}
+
+	void set(JNIEnv *env, jbyteArray f, int l){
+		if(l < 0 || l > len){
+			cerr << "Tried to set field with value that is too long " << l << " " << len << endl;	
+		}
+		len = l;
+		env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+	}
+
+	int compare(const Field &of) const{
+		return compare(field, len, of.field, of.len);
+	}
+
+	bool operator<(const Field &of) const{
+		return compare(of) < 0;	
+	}
+	
+	int32_t length() const {
+		return len;
+	}	
+
+	void fillIn(JNIEnv *env, jbyteArray d) const {
+		//TODO ensure lengths match up
+		env->SetByteArrayRegion(d, 0, len, (jbyte *)field);	
+	}
+
+ 	jbyteArray createJByteArray(JNIEnv *env) const{
+                jbyteArray valData = env->NewByteArray(len);
+                env->SetByteArrayRegion(valData, 0, len, (jbyte *)field);
+                return valData;
+        }
+
+	string toString() const{
+		return string((char *)field, len);
+	}
+
+	void clear(){
+		//delete(field);
+	}
+
+	void clear(LinkedBlockAllocator *lba){
+		lba->deleteLast(field);
+	}
+}; 
+
+struct LocalField : public Field {
+	LocalField(JNIEnv *env, jbyteArray f){
+		len = env->GetArrayLength(f);
+		field= new uint8_t[len];
+		env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+	}
+
+	~LocalField(){
+		delete(field);
+	}
+};
+#endif
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/Key.h
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/Key.h b/server/native/src/main/c++/nativeMap/Key.h
new file mode 100644
index 0000000..f902426
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/Key.h
@@ -0,0 +1,143 @@
+/*
+* 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.
+*/
+#include <algorithm>
+#include <stdint.h>
+#include <string.h>
+#include <string>
+#include <jni.h>
+
+using namespace std;
+
+class Key {
+
+public:
+	int32_t colFamilyOffset;
+	int32_t colQualifierOffset;
+	int32_t colVisibilityOffset;
+	int32_t totalLen;
+	
+	uint8_t *keyData;	
+	
+	int64_t timestamp;
+	bool deleted;
+
+	int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+		int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
+		
+		if(result != 0)
+			return result;
+		if(len1 == len2)
+			return 0;
+		if(len1 < len2)
+			return -1;
+
+		return 1;
+	}
+
+	/**
+	 * Constructor for testing purposes
+	 */
+
+	Key(){}
+
+	Key(const string &r, const string &cf, const string &cq, const string &cv, long ts, bool del){
+
+		colFamilyOffset = r.length();
+		colQualifierOffset = colFamilyOffset + cf.length();
+		colVisibilityOffset = colQualifierOffset + cq.length();
+		totalLen = colVisibilityOffset + cv.length();
+
+		keyData = new uint8_t[totalLen];
+
+		copy(r.begin(), r.end(), keyData);
+		copy(cf.begin(), cf.end(), keyData+colFamilyOffset);
+		copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
+		copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
+
+		timestamp = ts;
+		deleted = del;
+	}
+
+	/**
+	 * Constructor used for taking data from Java Key
+	 */
+	
+	Key(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
+
+		colFamilyOffset = cfo;
+		colQualifierOffset = cqo;
+		colVisibilityOffset = cvo;
+		totalLen = tl;
+		timestamp = ts;
+		deleted = del == JNI_TRUE ? true : false;
+
+		keyData = new uint8_t[totalLen];
+		env->GetByteArrayRegion(kd, 0, totalLen, (jbyte *)keyData);
+	} 
+
+	bool operator<(const Key &key) const{
+		int result = compare(keyData, colFamilyOffset, key.keyData, key.colFamilyOffset);
+		if(result != 0) return result < 0;
+
+		result = compare(keyData + colFamilyOffset, colQualifierOffset - colFamilyOffset, key.keyData + key.colFamilyOffset, key.colQualifierOffset - key.colFamilyOffset);
+		if(result != 0) return result < 0;
+
+		result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
+		if(result != 0) return result < 0;
+
+		result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
+		if(result != 0) return result < 0;
+
+		if(timestamp < key.timestamp){
+			return false;
+		}else if(timestamp > key.timestamp){
+			return true;
+		}
+
+		return deleted && !key.deleted;
+	}
+
+};
+
+
+class LocalKey : public Key {
+
+public:
+
+	JNIEnv *envPtr;
+	jbyteArray kd;
+	
+	LocalKey(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
+		envPtr = env;
+
+		colFamilyOffset = cfo;
+		colQualifierOffset = cqo;
+		colVisibilityOffset = cvo;
+		totalLen = tl;
+		timestamp = ts;
+		deleted = del == JNI_TRUE ? true : false;
+
+		this->kd = kd;
+		keyData = (uint8_t *)env->GetByteArrayElements((jbyteArray)kd, NULL);
+	}
+
+	~LocalKey(){
+		envPtr->ReleaseByteArrayElements(kd, (jbyte *)keyData, JNI_ABORT);
+	} 
+
+};
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/NativeMap.h
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/NativeMap.h b/server/native/src/main/c++/nativeMap/NativeMap.h
new file mode 100644
index 0000000..bc44a98
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/NativeMap.h
@@ -0,0 +1,208 @@
+/*
+* 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.
+*/
+#ifndef __NATIVE_MAP_A12__
+#define __NATIVE_MAP_A12__
+
+#include "SubKey.h"
+#include "Field.h"
+#include "BlockAllocator.h"
+#include <map>
+#include <vector>
+#include <iostream>
+
+using namespace std;
+
+typedef map<SubKey, Field, std::less<SubKey>,  BlockAllocator<std::pair<const SubKey, Field> > > ColumnMap;
+typedef map<Field, ColumnMap, std::less<Field>,  BlockAllocator<std::pair<const Field, ColumnMap> > > RowMap;
+
+
+struct NativeMapData {
+	LinkedBlockAllocator *lba;
+	RowMap rowmap;
+	int count;
+
+	NativeMapData(int blockSize, int bigBlockSize):lba(new LinkedBlockAllocator(blockSize, bigBlockSize)),
+							rowmap(RowMap(std::less<Field>(), BlockAllocator<std::pair<Field, ColumnMap> >(lba))){
+	}
+
+	~NativeMapData(){
+		rowmap.clear(); //if row map is not cleared here, it will be deconstructed after lba is deleted
+		delete(lba);
+	}
+};
+
+
+struct Iterator {
+	NativeMapData &nativeMap;
+	RowMap::iterator rowIter;
+	ColumnMap::iterator colIter;
+
+	Iterator(NativeMapData &nm, int32_t *ia):nativeMap(nm){
+		rowIter = nativeMap.rowmap.begin();
+		if(rowIter == nativeMap.rowmap.end()){
+			return;
+		}
+
+		colIter = rowIter->second.begin();
+
+		skipAndFillIn(ia, true);
+	}
+
+
+	Iterator(NativeMapData &nm, Field &row, SubKey &sk, int32_t *ia):nativeMap(nm){
+		rowIter = nativeMap.rowmap.lower_bound(row);
+		if(rowIter == nativeMap.rowmap.end()){
+			return;
+		}
+
+		//TODO use equals instead of compare
+		if(rowIter->first.compare(row) == 0){
+			colIter = rowIter->second.lower_bound(sk);
+		}else{
+			colIter = rowIter->second.begin();
+		}
+
+		skipAndFillIn(ia, true);
+	}
+
+	bool skipAndFillIn(int32_t *ia, bool firstCall)
+	{
+		bool rowChanged = false;
+	
+		while(colIter == rowIter->second.end()){
+			rowIter++;
+			rowChanged = true;
+			if(rowIter == nativeMap.rowmap.end()){
+				return false;
+			}
+			colIter = rowIter->second.begin();
+		}
+
+		ia[0] = (firstCall || rowChanged) ? rowIter->first.length() : -1;
+		ia[1] = colIter->first.getCFLen();
+		ia[2] = colIter->first.getCQLen();
+		ia[3] = colIter->first.getCVLen();
+		ia[4] = colIter->first.isDeleted() ? 1 : 0;
+		ia[5] = colIter->second.length();
+		ia[6] = colIter->first.getMC();
+	
+		return true;
+	}
+
+	bool atEnd(){
+		return rowIter == nativeMap.rowmap.end();
+	}
+
+	void advance(int32_t *ia){
+		colIter++;
+		skipAndFillIn(ia, false);
+	}
+};
+
+struct NativeMap : public NativeMapData {
+
+	NativeMap(int blockSize, int bigBlockSize):NativeMapData(blockSize, bigBlockSize){
+		count = 0;
+	}
+
+	~NativeMap(){
+
+	}
+
+
+	ColumnMap *startUpdate(JNIEnv * env, jbyteArray r){
+		Field row(lba, env, r);
+		return startUpdate(row);
+	}
+
+	ColumnMap *startUpdate(const char *r){
+
+		Field row(lba, r);	
+		return startUpdate(row);
+	}
+
+	ColumnMap *startUpdate(Field &row){
+		//cout << "Starting update "<<row.toString()<<endl;
+
+		pair<RowMap::iterator, bool> insertResult = rowmap.insert(pair<Field, ColumnMap>(row, ColumnMap(std::less<SubKey>(), BlockAllocator<std::pair<SubKey, Field> >(lba))));
+
+		if(!insertResult.second)
+			row.clear(lba);
+
+		return &(insertResult.first->second);
+
+	}
+
+	void update(ColumnMap *cm, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount){
+
+		SubKey sk(lba, env, cf, cq, cv, ts, del, mutationCount);
+		//cout << "Updating " << sk.toString() << " " << sk.getTimestamp() << " " << sk.isDeleted() << endl;
+		//do not bother allocating value if not needed
+		Field value(NULL, 0);
+
+		pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
+		if(insertResult.second){
+			insertResult.first->second  = Field(lba, env, val);
+			count++;
+		}else{
+			sk.clear(lba);
+			int valLen =  env->GetArrayLength(val);
+			if(valLen <= insertResult.first->second.length()){
+				insertResult.first->second.set(env, val, valLen);
+			}else{
+				insertResult.first->second.clear();
+				insertResult.first->second  = Field(lba, env, val, valLen);
+			} 
+		}
+	}
+
+	void update(ColumnMap *cm, const char *cf, const char *cq, const char *cv, long ts, bool del, const char *val, int valLen, int mutationCount){
+
+		SubKey sk(lba, cf, cq, cv, ts, del, mutationCount);
+		//do not bother allocating value if not needed
+		Field value(NULL, 0);
+
+		pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
+		if(insertResult.second){
+			insertResult.first->second  = Field(lba, val);
+			count++;
+		}else{
+			sk.clear(lba);
+			if(insertResult.first->second.length() <= valLen){
+				insertResult.first->second.set(val, valLen);
+			}else{
+				insertResult.first->second.clear();
+				insertResult.first->second  = Field(lba, val);
+			} 
+		}
+	}
+
+	Iterator *iterator(int32_t *ia){
+		return new Iterator(*this, ia);
+	}
+
+	Iterator *iterator(Field &row, SubKey &sk, int32_t *ia){
+		return new Iterator(*this, row, sk, ia);
+	}
+
+	int64_t getMemoryUsed(){
+	  return lba->getMemoryUsed();
+	}
+};
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/SubKey.h
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/SubKey.h b/server/native/src/main/c++/nativeMap/SubKey.h
new file mode 100644
index 0000000..0522308
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/SubKey.h
@@ -0,0 +1,187 @@
+/*
+* 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.
+*/
+#include <jni.h>
+#include <limits.h>
+#include "Field.h"
+#include "BlockAllocator.h"
+
+using namespace std;
+
+#ifndef __SUB_KEY__
+#define __SUB_KEY__
+
+class SubKey {
+
+public:
+
+	int32_t colQualifierOffset;
+	int32_t colVisibilityOffset;
+	int32_t totalLen;
+	uint8_t *keyData;	
+	int64_t timestamp;
+	int32_t mutationCount;
+	bool deleted;
+
+	int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+		int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
+		
+		if(result != 0)
+			return result;
+		if(len1 == len2)
+			return 0;
+		if(len1 < len2)
+			return -1;
+
+		return 1;
+	}
+
+	/**
+	 * Constructor for testing purposes
+	 */
+	SubKey(LinkedBlockAllocator *lba, const string &cf, const string &cq, const string &cv, int64_t ts, bool del, int32_t mc){
+
+		colQualifierOffset = cf.length();
+		colVisibilityOffset = colQualifierOffset + cq.length();
+		totalLen = colVisibilityOffset + cv.length();
+
+		keyData = (uint8_t *)lba->allocate(totalLen);
+
+		copy(cf.begin(), cf.end(), keyData);
+		copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
+		copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
+
+		timestamp = ts;
+		deleted = del;
+
+		mutationCount = mc;
+	}
+
+	SubKey(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, int32_t mc){
+
+		int cfLen = env->GetArrayLength(cf);
+		int cqLen = env->GetArrayLength(cq);
+		int cvLen = env->GetArrayLength(cv);
+
+		colQualifierOffset = cfLen;
+		colVisibilityOffset = colQualifierOffset + cqLen;
+		totalLen = colVisibilityOffset + cvLen;
+
+		if(lba == NULL)
+			keyData = new uint8_t[totalLen];
+		else
+			keyData = (uint8_t *)lba->allocate(totalLen);
+
+
+		env->GetByteArrayRegion(cf, 0, cfLen, (jbyte *)keyData);
+		env->GetByteArrayRegion(cq, 0, cqLen, (jbyte *)(keyData+colQualifierOffset));
+		env->GetByteArrayRegion(cv, 0, cvLen, (jbyte *)(keyData+colVisibilityOffset));
+
+		timestamp = ts;
+		deleted = del;
+
+		mutationCount = mc;
+	}
+
+
+	bool operator<(const SubKey &key) const{
+
+		int result = compare(keyData, colQualifierOffset, key.keyData, key.colQualifierOffset);
+		if(result != 0) return result < 0;
+
+		result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
+		if(result != 0) return result < 0;
+
+		result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
+		if(result != 0) return result < 0;
+
+		if(timestamp < key.timestamp){
+			return false;
+		}else if(timestamp > key.timestamp){
+			return true;
+		}
+
+		if(deleted != key.deleted)
+			return deleted && !key.deleted;
+	
+		return mutationCount > key.mutationCount;
+	}
+
+	void clear(){
+		//delete(keyData);
+	}
+
+	void clear(LinkedBlockAllocator *lba){
+		lba->deleteLast(keyData);
+	}
+
+	int64_t bytesUsed() const{
+		return totalLen + 9;
+	}
+
+	bool isDeleted() const{
+		return deleted;
+	}
+
+	int32_t getCFLen() const{
+		return colQualifierOffset;
+	}
+	
+	int32_t getCQLen() const {
+		return colVisibilityOffset - colQualifierOffset;
+	}
+
+	int32_t getCVLen() const {
+		return totalLen - colVisibilityOffset;
+	}
+
+	const Field getCF() const{
+		return Field(keyData, getCFLen());
+	}
+
+	const Field getCQ() const{
+		return Field(keyData + colQualifierOffset, getCQLen());
+	}
+
+	const Field getCV() const{
+		return Field(keyData + colVisibilityOffset, getCVLen());
+	}
+
+	string toString() const{
+		return getCF().toString()+":"+getCQ().toString()+":"+getCV().toString();
+	}
+
+	int64_t getTimestamp() const{
+		return timestamp;
+	}
+
+	int32_t getMC() const{
+		return mutationCount;
+	}
+
+};
+
+struct LocalSubKey : public SubKey {
+	
+	LocalSubKey(JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del):SubKey(NULL, env, cf, cq, cv, ts, del, INT_MAX){}
+
+	~LocalSubKey(){
+		delete(keyData);
+	}
+};
+
+#endif
+ 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
----------------------------------------------------------------------
diff --git a/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc b/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
new file mode 100644
index 0000000..4c17fb3
--- /dev/null
+++ b/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
@@ -0,0 +1,130 @@
+/*
+* 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.
+*/
+#include "org_apache_accumulo_tserver_NativeMap.h"
+#include "SubKey.h"
+#include "Field.h"
+#include "NativeMap.h"
+#include <map>
+#include <vector>
+#include <jni.h>
+#include <iostream>
+
+#ifdef _POSIX_MEMLOCK
+#include <sys/mman.h>
+#endif
+
+using namespace std;
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNM(JNIEnv *env, jclass cls) {
+	return (jlong)(new NativeMap(1<<17, 1<<11));
+}
+
+JNIEXPORT jint JNICALL Java_org_apache_accumulo_tserver_NativeMap_sizeNM(JNIEnv *env, jclass cls, jlong nm) {
+	return ((NativeMap *)nm)->count;
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_memoryUsedNM(JNIEnv *env, jclass cls, jlong nm) {
+	return ((NativeMap *)nm)->getMemoryUsed();
+}
+
+JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_singleUpdate(JNIEnv *env, jclass cls, jlong nm, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount) {
+	jlong uid = Java_org_apache_accumulo_tserver_NativeMap_startUpdate(env, cls, nm, r);
+	Java_org_apache_accumulo_tserver_NativeMap_update(env, cls, nm, uid, cf, cq, cv, ts, del, val, mutationCount); 
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_startUpdate(JNIEnv *env, jclass cls, jlong nm, jbyteArray r) {
+	NativeMap *nativeMap = (NativeMap *)nm;
+	ColumnMap *cm = nativeMap->startUpdate(env, r);
+	return (jlong)cm;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_update(JNIEnv *env, jclass cls, jlong nm, jlong uid, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount) {
+	NativeMap *nativeMap = (NativeMap *)nm;
+	nativeMap->update((ColumnMap *)uid, env, cf, cq, cv, ts, del, val, mutationCount);
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_deleteNM(JNIEnv *env, jclass cls, jlong nm) {
+	NativeMap *nativeMap = (NativeMap *)nm;
+	delete(nativeMap);
+  return 0;
+}
+
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNMI__J_3I(JNIEnv *env, jclass cls, jlong nm, jintArray lens) {
+	NativeMap *nativeMap = (NativeMap *)nm;
+	int32_t ia[7];
+	Iterator *iter = nativeMap->iterator(ia);
+	if (iter->atEnd()) {
+		delete(iter);
+		return 0;
+	}
+	env->SetIntArrayRegion(lens, 0, 7, ia);	
+	return (jlong)iter;	
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNMI__J_3B_3B_3B_3BJZ_3I(JNIEnv *env, jclass cls, jlong nm, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jintArray lens) {
+
+  NativeMap *nativeMap = (NativeMap *)nm;
+	LocalField row(env, r);
+	LocalSubKey sk(env, cf, cq, cv, ts, del);
+
+	int32_t ia[7];
+	Iterator *iter = nativeMap->iterator(row, sk, ia);
+
+	if(iter->atEnd()) {
+		delete(iter);
+		return 0;
+	}
+
+	env->SetIntArrayRegion(lens, 0, 7, ia);	
+	return (jlong)iter;	
+}
+
+JNIEXPORT jboolean JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiNext(JNIEnv *env, jclass cls, jlong ip, jintArray lens) {
+	Iterator &iter = *((Iterator *)ip);
+
+	int32_t ia[7];
+	iter.advance(ia);
+	if(iter.atEnd()) {
+		return false;
+	}	
+
+	env->SetIntArrayRegion(lens, 0, 7, ia);	
+	return true;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiGetData(JNIEnv *env, jclass cls, jlong ip, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jbyteArray val) {
+	Iterator &iter = *((Iterator *)ip);
+	if(r != NULL) {
+		iter.rowIter->first.fillIn(env, r);
+	}
+
+	iter.colIter->first.getCF().fillIn(env, cf);
+	iter.colIter->first.getCQ().fillIn(env, cq);
+	iter.colIter->first.getCV().fillIn(env, cv);
+	iter.colIter->second.fillIn(env, val);
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiGetTS(JNIEnv *env, jclass cls, jlong ip) {
+	Iterator &iter = *((Iterator *)ip);
+	return iter.colIter->first.getTimestamp();
+}
+
+JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_deleteNMI(JNIEnv *env, jclass cls, jlong ip) {
+	delete((Iterator *)ip);	
+}
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/resources/LICENSE
----------------------------------------------------------------------
diff --git a/server/native/src/main/resources/LICENSE b/server/native/src/main/resources/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/server/native/src/main/resources/LICENSE
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/main/resources/Makefile
----------------------------------------------------------------------
diff --git a/server/native/src/main/resources/Makefile b/server/native/src/main/resources/Makefile
new file mode 100644
index 0000000..01a109b
--- /dev/null
+++ b/server/native/src/main/resources/Makefile
@@ -0,0 +1,41 @@
+# 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.
+
+SRCS=$(wildcard nativeMap/*.cc)
+HDRS=$(wildcard nativeMap/*.h) $(wildcard javah/*.h)
+CXX=g++
+
+ifeq ($(shell uname),Linux)
+	JAVA_HOME=$(shell dirname $$(dirname $$(readlink -ef $$(which javah))))
+	NATIVE_LIB := libaccumulo.so
+	CXXFLAGS=-g -fPIC -shared -O2 -fno-omit-frame-pointer -fno-strict-aliasing -Wall -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -Ijavah
+endif
+
+ifeq ($(shell uname),Darwin)
+	JAVA_HOME=$(shell /usr/libexec/java_home)
+	NATIVE_LIB:= libaccumulo.jnilib
+	CXXFLAGS=-m64 -dynamiclib -O3 -I$(JAVA_HOME)/include -Ijavah
+endif
+
+all : $(NATIVE_LIB)
+
+$(NATIVE_LIB) : $(SRCS) $(HDRS)
+	$(CXX) $(CXXFLAGS) -m64 -o $@ $(SRCS) 
+
+test : testJavaHome
+
+testJavaHome :
+	@echo JAVA_HOME is $(JAVA_HOME)
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/test/c++/nativeMap/test.cc
----------------------------------------------------------------------
diff --git a/server/native/src/test/c++/nativeMap/test.cc b/server/native/src/test/c++/nativeMap/test.cc
new file mode 100644
index 0000000..6beaea6
--- /dev/null
+++ b/server/native/src/test/c++/nativeMap/test.cc
@@ -0,0 +1,134 @@
+/*
+* 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.
+*/
+#include "NativeMap.h"
+#include "util.h"
+#include "Key.h"
+#include <stdio.h>
+
+void runTest(int numRows, int numCf, int numCq, int rowLen, int cfLen, int cqLen, int cvLen, int valLen, bool testOld){
+
+	map<std::string, std::string> tm;
+	tm.insert(pair<string, string>("a","b"));
+	tm.insert(pair<string, string>("a","c")).first->second="c";
+
+	cout << tm["a"] << std::endl;
+
+	size_t initialMemUsage = getMemUsage();
+
+	NativeMap nm(1<<17, 1<<11);
+
+	cout << " size pair<Key, Field>       : " << sizeof(std::pair<Key, Field>) << endl;
+	cout << " size pair<Field, ColumnMap> : " << sizeof(std::pair<Field, ColumnMap>) << endl;
+	cout << " size pair<SubKey, Field>    : " << sizeof(std::pair<SubKey, Field>) << endl;
+
+	map<Key, Field> oldMap;
+
+	int entries = 0;
+
+
+	char rowFmt[16];
+	char cfFmt[16];
+	char cqFmt[16];
+	char cvFmt[16];
+	char valFmt[16];
+
+	sprintf(rowFmt, "%s0%dd", "%", rowLen);
+	sprintf(cfFmt, "%s0%dd", "%", cfLen);
+	sprintf(cqFmt, "%s0%dd", "%", cqLen);
+	sprintf(cvFmt, "%s0%dd", "%", cvLen);
+	sprintf(valFmt, "%s0%dd", "%", valLen);
+	
+	for(int r = 0; r < numRows; r++){
+		char row[rowLen+1];
+		snprintf(row, rowLen+1, rowFmt, r);
+
+		ColumnMap *cmt = NULL;
+		if(!testOld){
+			cmt = nm.startUpdate(row);
+		}
+
+		for(int cf = 0; cf < numCf; cf++){
+			char colf[cfLen+1];
+			snprintf(colf, cfLen+1, cfFmt, cf);
+
+			for(int cq = 0; cq < numCq; cq++){
+				char colq[cqLen+1];
+				snprintf(colq, cqLen+1, cqFmt, cq);
+
+				char colv[cvLen+1];
+				snprintf(colv, cvLen+1, cvFmt, 1);
+
+				char val[valLen+1];
+				snprintf(val, valLen+1, valFmt, entries);
+				
+				if(!testOld){	
+				  nm.update(cmt, colf, colq, colv, 5, false, val, valLen, cf * numCq + numCq);	
+				}else{
+					oldMap.insert(pair<Key, Field>(Key(row, colf, colq, colv, 5, false), Field(val)));
+				}
+
+
+				entries++;
+	
+			}
+		}
+	}
+
+	int expectedRowBytes = rowLen * numRows;
+	int expectedEntryBytes = entries * (cfLen + cqLen + cvLen + 9 + valLen);
+
+	cout << "row bytes   : " <<  expectedRowBytes << endl;
+	cout << "entry bytes : " <<  expectedEntryBytes << endl;
+	cout << "count : " << nm.count << "   " << entries << endl;
+	size_t memUsage = getMemUsage();
+	cout << " mem delta " << memUsage - initialMemUsage << endl;
+	cout << " mem usage " << memUsage << endl;
+	cout << " simple overhead " << ( (getMemUsage() - initialMemUsage) - (entries * (rowLen + cfLen + cqLen + cvLen + 9 + valLen) ) ) / ((double)entries) << endl;
+
+	if(testOld){
+		map<Key, Field>::iterator iter = oldMap.begin();
+		while(iter != oldMap.end()){
+			delete(iter->first.keyData);
+			delete(iter->second.field);
+			iter++;
+		}
+	}
+
+}
+
+int main(int argc, char **argv){
+	int numRows,numCf, numCq, rowLen, cfLen, cqLen, cvLen, valLen, testOld;
+
+	if(argc != 10){
+		cout << "Usage : " << argv[0] << " <numRows> <numCf> <numCq> <rowLen> <cfLen> <cqLen> <cvLen> <valLen> <testOld>" << endl;
+		return -1;
+	}	
+
+	sscanf(argv[1], "%d", &numRows);
+	sscanf(argv[2], "%d", &numCf);
+	sscanf(argv[3], "%d", &numCq);
+	sscanf(argv[4], "%d", &rowLen);
+	sscanf(argv[5], "%d", &cfLen);
+	sscanf(argv[6], "%d", &cqLen);
+	sscanf(argv[7], "%d", &cvLen);
+	sscanf(argv[8], "%d", &valLen);
+	sscanf(argv[9], "%d", &testOld);
+	
+	for(int i = 0; i < 3; i++){
+		runTest(numRows,numCf, numCq, rowLen, cfLen, cqLen, cvLen, valLen, testOld);
+	}
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/test/c++/nativeMap/util.cc
----------------------------------------------------------------------
diff --git a/server/native/src/test/c++/nativeMap/util.cc b/server/native/src/test/c++/nativeMap/util.cc
new file mode 100644
index 0000000..b9393ee
--- /dev/null
+++ b/server/native/src/test/c++/nativeMap/util.cc
@@ -0,0 +1,32 @@
+/*
+* 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.
+*/
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util.h"
+
+size_t getMemUsage(){
+	pid_t pid = getpid();
+	char cmd[1000];
+	sprintf(cmd, "cat /proc/%d/status | grep VmData |  awk '{print $2}'", pid);
+	FILE *f = popen(cmd, "r");
+	int dataSize;
+	fscanf(f, "%d\n", &dataSize);
+	pclose(f);
+	return (size_t)dataSize * (size_t)1024;
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/598821cd/server/native/src/test/c++/nativeMap/util.h
----------------------------------------------------------------------
diff --git a/server/native/src/test/c++/nativeMap/util.h b/server/native/src/test/c++/nativeMap/util.h
new file mode 100644
index 0000000..65d5721
--- /dev/null
+++ b/server/native/src/test/c++/nativeMap/util.h
@@ -0,0 +1,19 @@
+/*
+* 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.
+*/
+
+size_t getMemUsage();
+


Mime
View raw message