geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [40/51] [partial] geode git commit: Software Grant Agreement (SGA) from Pivotal for Apache Geode
Date Fri, 13 Jan 2017 22:46:24 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/Packer.psm1
----------------------------------------------------------------------
diff --git a/packer/windows/Packer.psm1 b/packer/windows/Packer.psm1
new file mode 100644
index 0000000..19e13fe
--- /dev/null
+++ b/packer/windows/Packer.psm1
@@ -0,0 +1,218 @@
+Set-PSDebug -Trace 0
+
+function Install-Package {
+  [CmdletBinding()]
+  param (
+    [parameter(Mandatory=$false,Position=0)]
+    [string]$Uri,
+    
+    [parameter(Mandatory=$false)]
+    [string]$Installer,
+    
+    [parameter(Mandatory=$false)]
+    [string]$Log,
+
+    [parameter(Mandatory=$false)]
+    [string[]]$ArgumentList=@(),
+
+    [parameter(Mandatory=$false)]
+    [string]$Hash,
+
+    [parameter(Mandatory=$false)]
+    [string]$DestinationPath,
+
+    [parameter(Mandatory=$false)]
+    [System.Collections.IDictionary]$DownloadHeaders=@{},
+
+    [parameter(Mandatory=$false)]
+    [string]$DownloadMethod="Get",
+
+    [parameter(Mandatory=$false)]
+    [string]$MsuPackage
+  )
+  PROCESS {
+    Push-Location -Path $Env:temp
+  
+    if (-not $Installer) {
+      $Installer = $Env:temp + "\" + $Uri.Split('/')[-1]
+    }
+
+    Write-Verbose "Install-Package: Uri=$Uri, Installer=$Installer, ArgumentList=$ArgumentList Log=$Log"
+    
+    if ($Uri) {
+
+    if (!((Test-Path $Installer) -and ((Get-FileHash $Installer).hash -eq "$Hash"))) {
+
+        if ($DownloadMethod -eq 'GET') {
+        $ds = New-Object psobject -Property @{downloadProgress = 0; downloadComplete = $false; error = 0}
+      
+        $wc = New-Object System.Net.WebClient
+      
+        if ($DownloadHeaders.Count -gt 0) {
+          $a = $DownloadHeaders.GetEnumerator() | % { "$($_.Name):$($_.Value)" }
+          $wc.Headers.Add($a)
+        }
+      
+        $eventDataComplete = Register-ObjectEvent $wc DownloadFileCompleted `
+            -MessageData $ds `
+            -Action { 
+                $event.MessageData.downloadComplete = $true
+                $event.MessageData.error = $EventArgs.Error
+            }
+      
+        $eventDataProgress = Register-ObjectEvent $wc DownloadProgressChanged `
+            -MessageData $ds `
+            -Action {
+                $event.MessageData.downloadProgress = $EventArgs.ProgressPercentage
+            }    
+      
+        while ($true) {
+        $ds.error = 0
+        $ds.downloadComplete = $false
+        $ds.downloadProgress = 0
+        
+        try {
+            $wc.DownloadFileAsync($Uri, $Installer)
+        } catch {
+            Write-Host $_.Exception.Message
+        }
+      
+      
+        $p = 0;
+        while (!$ds.downloadComplete) {
+        if ($ds.downloadProgress -gt $p) {
+            $p = $ds.downloadProgress;
+            Write-Host "Downloading... ($($ds.downloadProgress)%)"
+            Start-Sleep -m 100
+        }
+        }
+        if ($ds.error) {
+        Write-Host "Error: $($ds.error)"
+        } else {
+        break;
+        }
+        }
+      } else {
+        # POST
+        Invoke-WebRequest -Uri $Uri `
+                        -Headers $DownloadHeaders `
+                        -Method $DownloadMethod `
+                        -OutFile $Installer
+      }
+    }
+    }
+
+    Write-Host "Installing..."
+    if ($Installer -match "\.msi$") {
+      Write-Verbose "Installing via MSI"
+      $Log = "$Installer.log"
+      $ArgumentList = @("/package", $Installer, "/quiet", "/log", "$Log") + $ArgumentList
+      $Installer = "msiexec";
+    } elseif ($Installer -match "\.msu$") {
+      Write-Verbose "Installing via MSU"
+      $Log = "$Installer.log"
+      Start-Process -FilePath "wusa" -ArgumentList @($Installer, "/extract:.")
+      $ArgumentList = @("/Online", "/Add-Package", "/NoRestart", "/PackagePath:$MsuPackage") + $ArgumentList
+      $Installer = "dism";
+    } elseif ($Installer -match "\.zip$") {
+      Write-Verbose "Installing via ZIP"
+      Expand-Archive -Path $Installer -DestinationPath $DestinationPath -Force -Verbose
+      $Installer = "";
+    }
+
+    if ($Installer) {
+    Write-Verbose "Installer=$Installer, ArgumentList=$ArgumentList"
+    $ip = Start-Process -FilePath $Installer -ArgumentList $ArgumentList -NoNewWindow -PassThru
+    if (!$ip) {
+      throw "Error starting installer. Installer=$Installer, ArgumentList=$ArgumentList"
+    }
+    $handle = $ip.Handle
+
+    if ($log) {
+      $lp = Start-Process -FilePath powershell.exe -ArgumentList @("-Command", "& {Import-Module Packer; Get-Tail -FilePath $Log -Follow}") -NoNewWindow -PassThru
+      #$lp= &{ Tail-File $Log -Follow }
+      #$lp
+    }
+
+    while(-not $ip.HasExited) {
+      Write-Host -NoNewline '.'
+#      if ($Log) {
+#        $c = Get-Content -Path $Log -Tail 1
+#        Write-Host ">> $c"
+#      }
+      sleep 1
+    }
+    
+    $lp | Stop-Process -ErrorAction SilentlyContinue
+
+    Write-Verbose "Exit Code: $($ip.ExitCode)"
+    if ($ip.ExitCode -eq 0) {
+      Write-Host "Installation complete."
+    } elseif ($ip.ExitCode -eq 3010) {
+      Write-Host "Restart required to complete installation."
+    } else {
+      throw "Error while installing. Installer exit code $($ip.ExitCode). Installer=$Installer, ArgumentList=$ArgumentList"
+    }
+    }
+    
+    Pop-Location
+  }
+}
+
+function Get-Tail { 
+ [CmdletBinding()]
+  param (
+    [parameter(Mandatory=$true,Position=0)]
+    [string]$FilePath,
+
+    [parameter(Mandatory=$false)]
+    [int]$Offset,
+    
+    [parameter(Mandatory=$false)]
+    [switch]$Follow
+  )
+  PROCESS {
+    Write-Verbose "Tail-File: FilePath=$FilePath, Follow=$Follow"
+    
+    while (1) {
+      $ci = get-childitem $FilePath -ErrorAction SilentlyContinue
+      if ($ci) { break }
+      Start-Sleep -m 100
+    }
+    
+    $fullName = $ci.FullName
+    
+    $reader = new-object System.IO.StreamReader(New-Object IO.FileStream($fullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [IO.FileShare]::ReadWrite))
+    #start at the end of the file
+    $lastMaxOffset = $reader.BaseStream.Length - $Offset
+
+    while ($true)
+    {
+      $reader = new-object System.IO.StreamReader(New-Object IO.FileStream($fullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [IO.FileShare]::ReadWrite))
+      #if the file size has not changed, idle
+      if ($reader.BaseStream.Length -ge $lastMaxOffset) {
+        #seek to the last max offset
+        $reader.BaseStream.Seek($lastMaxOffset, [System.IO.SeekOrigin]::Begin) | out-null
+
+        #read out of the file until the EOF
+        $line = ""
+        while (($line = $reader.ReadLine()) -ne $null) {
+            write-output $line
+        }
+
+        #update the last max offset
+        $lastMaxOffset = $reader.BaseStream.Position
+      } elseif ($reader.BaseStream.Length -lt $lastMaxOffset) {
+        write-output "File truncated"
+        $lastMaxOffset = 0;
+      }
+  
+      if($Follow){
+          Start-Sleep -m 100
+      } else {
+          break;
+      }
+    }
+    
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/add-user-build.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/add-user-build.ps1 b/packer/windows/add-user-build.ps1
new file mode 100644
index 0000000..3a488b6
--- /dev/null
+++ b/packer/windows/add-user-build.ps1
@@ -0,0 +1,13 @@
+$user = "build"
+$pass = "p1votal!"
+
+net.exe user $user $pass /add
+net.exe localgroup Administrators $user /add
+
+$spw = ConvertTo-SecureString $pass -AsPlainText -Force
+$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$spw
+Start-Process cmd /c -WindowStyle Hidden -Credential $cred -ErrorAction SilentlyContinue
+
+
+schtasks.exe /Create /TN init-user-build /RU SYSTEM /SC ONSTART /TR "powershell.exe -File 'C:\Users\build\init-user-build.ps1'" 
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/buildenv.bat
----------------------------------------------------------------------
diff --git a/packer/windows/buildenv.bat b/packer/windows/buildenv.bat
new file mode 100644
index 0000000..f46b941
--- /dev/null
+++ b/packer/windows/buildenv.bat
@@ -0,0 +1,10 @@
+@rem Fixup ENV issues with SSH
+set APPDATA=C:\Users\build\AppData\Roaming
+set LOCALAPPDATA=C:\Users\build\AppData\Local
+set TEMP=C:\Users\build\AppData\Local\Temp\3
+set TMP=C:\Users\build\AppData\Local\Temp\3
+if not exist %TEMP% mkdir %TEMP%
+
+@rem Setup VC
+call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %*
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/cleanup.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/cleanup.ps1 b/packer/windows/cleanup.ps1
new file mode 100644
index 0000000..1f9164e
--- /dev/null
+++ b/packer/windows/cleanup.ps1
@@ -0,0 +1,22 @@
+# Remove admin ssh keys
+Remove-Item C:\Users\Administrator\.ssh -Recurse -Force -ErrorAction SilentlyContinue
+
+# Cleanup temp
+Get-ChildItem $env:tmp -Recurse | Remove-Item -Recurse -force -ErrorAction SilentlyContinue
+Get-ChildItem ([environment]::GetEnvironmentVariable("temp","machine")) -Recurse| Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
+
+# Cleanup Ec2ConfigService
+Remove-Item $Env:ProgramFiles\Amazon\Ec2ConfigService\Scripts\UserScript.ps1 -Force -ErrorAction SilentlyContinue
+Remove-Item $Env:ProgramFiles\Amazon\Ec2ConfigService\Logs -Recurse -Force -ErrorAction SilentlyContinue
+
+# TODO debuggin
+exit 0
+
+# Cleanup Windows SxS
+Dism.exe /online /Cleanup-Image /StartComponentCleanup
+
+# Cleanup Event Log
+Get-EventLog -List | foreach {Clear-EventLog -Log $_.Log}
+
+# Defrag
+defrag.exe C: /h /u /v /x

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/init-ssh.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/init-ssh.ps1 b/packer/windows/init-ssh.ps1
new file mode 100644
index 0000000..e4763d0
--- /dev/null
+++ b/packer/windows/init-ssh.ps1
@@ -0,0 +1,12 @@
+# TODO host keys
+
+$ssh = "C:\Users\Administrator\.ssh"
+$authorized_keys = "$ssh\authorized_keys"
+if ( -not (Test-Path $authorized_keys -PathType Leaf) ) {
+
+  write-host "Installing SSH authorized key"
+
+  mkdir -p $ssh -ErrorAction SilentlyContinue
+
+  Invoke-WebRequest -Uri 'http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key' -OutFile $authorized_keys
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/init-user-build.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/init-user-build.ps1 b/packer/windows/init-user-build.ps1
new file mode 100644
index 0000000..c87e6c5
--- /dev/null
+++ b/packer/windows/init-user-build.ps1
@@ -0,0 +1,14 @@
+$ssh = "C:\Users\build\.ssh"
+$authorized_keys = "$ssh\authorized_keys"
+if ( -not (Test-Path $authorized_keys -PathType Leaf) ) {
+
+  write-host "Installing SSH authorized key"
+
+  mkdir -p $ssh -ErrorAction SilentlyContinue
+
+  Invoke-WebRequest -Uri 'http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key' -OutFile $authorized_keys
+  
+  Stop-Service sshd
+  Start-Service sshd
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-chocolatey.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-chocolatey.ps1 b/packer/windows/install-chocolatey.ps1
new file mode 100644
index 0000000..11de9a1
--- /dev/null
+++ b/packer/windows/install-chocolatey.ps1
@@ -0,0 +1,10 @@
+$ErrorActionPreference = "Stop"
+
+write-host "Installing Chocolatey"
+
+# Avoid bug in 7zip when running via WinRM
+$Env:chocolateyUseWindowsCompression = $true
+
+iwr https://chocolatey.org/install.ps1 | iex
+
+write-host "Chocolatey Installed"

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-cygwin.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-cygwin.ps1 b/packer/windows/install-cygwin.ps1
new file mode 100644
index 0000000..55bfdc0
--- /dev/null
+++ b/packer/windows/install-cygwin.ps1
@@ -0,0 +1,23 @@
+$ErrorActionPreference = "Stop"
+
+# Chocolatey broken
+#choco install cygwin cyg-get -confirm
+#cyg-get git make
+#exit 0
+
+Import-Module Packer
+
+Install-Package https://cygwin.com/setup-x86_64.exe `
+    -Hash 08079A13888B74F6466DEF307A687E02CB26FC257EA2FA78D40F02E28330FD56 `
+    -ArgumentList @(
+        "--quiet-mode",
+        "--verbose",
+        "--site", "http://cygwin.osuosl.org", 
+        "--packages", "git,patch,make"
+        )
+
+# Set Cygwin home to Windows profile
+Add-Content C:\cygwin64\etc\nsswitch.conf "db_home: /%H"
+
+# Remove Perl to avoid conflicts with AvtivePerl
+Remove-Item -Path C:\cygwin64\bin\perl.exe

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-gemfire.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-gemfire.ps1 b/packer/windows/install-gemfire.ps1
new file mode 100644
index 0000000..294a90d
--- /dev/null
+++ b/packer/windows/install-gemfire.ps1
@@ -0,0 +1,7 @@
+$ErrorActionPreference = "Stop"
+Import-Module Packer -Force
+
+mkdir C:\gemfire
+cd C:\gemfire
+cmake -E tar zxf $Home\gemfire.tar.gz
+rm $Home\gemfire.tar.gz

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-gnuwin.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-gnuwin.ps1 b/packer/windows/install-gnuwin.ps1
new file mode 100644
index 0000000..d89dbd4
--- /dev/null
+++ b/packer/windows/install-gnuwin.ps1
@@ -0,0 +1,8 @@
+$ErrorActionPreference = "Stop"
+
+choco install gnuwin --allowEmptyChecksums -confirm
+
+# Fixup system path since installer puts it in user path
+$env:Path += ";" + "C:\GnuWin\bin"
+
+[Environment]::SetEnvironmentVariable( "Path", $env:Path, [System.EnvironmentVariableTarget]::Machine )

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-perl.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-perl.ps1 b/packer/windows/install-perl.ps1
new file mode 100644
index 0000000..fc5f08a
--- /dev/null
+++ b/packer/windows/install-perl.ps1
@@ -0,0 +1,6 @@
+$ErrorActionPreference = "Stop"
+Import-Module Packer
+
+Install-Package http://downloads.activestate.com/ActivePerl/releases/5.22.1.2201/ActivePerl-5.22.1.2201-MSWin32-x64-299574.msi `
+    -Hash 214083166032FBF61F20BB4C65B0610508B90101910F3293B67BD56619E6444D `
+    -ArgumentList @("PERL_PATH=Yes", "PERL_EXT=Yes")

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-ssh.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-ssh.ps1 b/packer/windows/install-ssh.ps1
new file mode 100644
index 0000000..1cc5f30
--- /dev/null
+++ b/packer/windows/install-ssh.ps1
@@ -0,0 +1,25 @@
+# Install sshd
+
+write-host "Installing OpenSSH"
+choco install win32-openssh -version 2016.05.30 -params '"/SSHServerFeature /KeyBasedAuthenticationFeature"' -confirm 
+
+# Chocolatey installer fails to setup permissions correctly via WinRM these scripts until fixed
+Push-Location
+cd "C:\Program Files\OpenSSH-Win64"
+& "C:\Program Files\OpenSSH-Win64\install-sshd.ps1"
+Set-Service sshd -StartupType Automatic
+Set-Service ssh-agent -StartupType Automatic
+& "C:\Program Files\OpenSSH-Win64\install-sshlsa.ps1"
+Pop-Location
+
+(Get-Content "C:\Program Files\OpenSSH-Win64\sshd_config") -replace 'C:/Program Files/OpenSSH', 'C:/Program Files/OpenSSH-Win64' | Set-Content "C:\Program Files\OpenSSH-Win64\sshd_config"
+
+# Configure services to restart after failure
+sc.exe failure sshd reset= 86400 actions= run/1000 command= "C:\Program Files\OpenSSH-Win64\sshd-recovery.bat"
+sc.exe failure ssh-agent reset= 86400 actions= restart/1000
+
+sc.exe sdset "sshd" "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RPWPDTLO;;;S-1-5-80-3847866527-469524349-687026318-516638107-1125189541)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"
+sc.exe sdset "ssh-agent" "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)(A;;RPWPDTLO;;;S-1-5-80-3847866527-469524349-687026318-516638107-1125189541)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"
+
+schtasks.exe /Create /TN init-ssh /RU SYSTEM /SC ONSTART /TR "powershell.exe -File 'C:\Program Files\Amazon\Ec2ConfigService\Scripts\init-ssh.ps1'" 
+#debug schtasks.exe /Query /TN init-ssh /XML

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-vs-2013-community.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-vs-2013-community.ps1 b/packer/windows/install-vs-2013-community.ps1
new file mode 100644
index 0000000..4e96cd7
--- /dev/null
+++ b/packer/windows/install-vs-2013-community.ps1
@@ -0,0 +1,12 @@
+# TODO AdminDeploy.xml
+# vs_community.exe /AdminFile C:\Users\Administrator\AdminDeployment.xml /Log setup.log /Passive
+Set-PSDebug -Trace 0
+
+Import-Module Packer
+
+$log = "vs_community.log"
+
+Install-Package https://download.microsoft.com/download/A/A/D/AAD1AA11-FF9A-4B3C-8601-054E89260B78/vs_community.exe `
+    -Hash EA57DF0294AE3CE4B893D19D497AEC02D1627F40B9576BC7013588DF79A0C528 `
+    -ArgumentList @("/quiet", "/log", $log) `
+    -Log $log -Verbose

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-windows-8-wmf-5.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-windows-8-wmf-5.ps1 b/packer/windows/install-windows-8-wmf-5.ps1
new file mode 100644
index 0000000..bd7cb93
--- /dev/null
+++ b/packer/windows/install-windows-8-wmf-5.ps1
@@ -0,0 +1,7 @@
+$ErrorActionPreference = "Stop"
+
+Import-Module Packer
+
+Install-Package https://download.microsoft.com/download/2/C/6/2C6E1B4A-EBE5-48A6-B225-2D2058A9CEFB/W2K12-KB3134759-x64.msu `
+    -Hash 6E59CEC4BD30C505F426A319673A13C4A9AA8D8FF69FD0582BFA89F522F5FF00 `
+    -MsuPackage .\Windows8-RT-KB3134759-x64.cab 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/install-windows-8.1-2012-r2-wmf-5.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/install-windows-8.1-2012-r2-wmf-5.ps1 b/packer/windows/install-windows-8.1-2012-r2-wmf-5.ps1
new file mode 100644
index 0000000..84eda58
--- /dev/null
+++ b/packer/windows/install-windows-8.1-2012-r2-wmf-5.ps1
@@ -0,0 +1,6 @@
+$ErrorActionPreference = "Stop"
+
+Import-Module Packer
+
+Install-Package https://download.microsoft.com/download/2/C/6/2C6E1B4A-EBE5-48A6-B225-2D2058A9CEFB/Win8.1AndW2K12R2-KB3134758-x64.msu `
+    -MsuPackage .\WindowsBlue-KB3134758-x64.cab
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/run-sshd-as-build.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/run-sshd-as-build.ps1 b/packer/windows/run-sshd-as-build.ps1
new file mode 100755
index 0000000..06844a0
--- /dev/null
+++ b/packer/windows/run-sshd-as-build.ps1
@@ -0,0 +1,92 @@
+$accountToAdd = "build"
+
+#written by Ingo Karstein, http://blog.karstein-consulting.com
+#  v1.0, 01/03/2014
+
+## <--- Configure here
+
+if( [string]::IsNullOrEmpty($accountToAdd) ) {
+	Write-Host "no account specified"
+	exit
+}
+
+## ---> End of Config
+
+$sidstr = $null
+try {
+	$ntprincipal = new-object System.Security.Principal.NTAccount "$accountToAdd"
+	$sid = $ntprincipal.Translate([System.Security.Principal.SecurityIdentifier])
+	$sidstr = $sid.Value.ToString()
+} catch {
+	$sidstr = $null
+}
+
+Write-Host "Account: $($accountToAdd)" -ForegroundColor DarkCyan
+
+if( [string]::IsNullOrEmpty($sidstr) ) {
+	Write-Host "Account not found!" -ForegroundColor Red
+	exit -1
+}
+
+Write-Host "Account SID: $($sidstr)" -ForegroundColor DarkCyan
+
+$tmp = [System.IO.Path]::GetTempFileName()
+
+Write-Host "Export current Local Security Policy" -ForegroundColor DarkCyan
+secedit.exe /export /cfg "$($tmp)" 
+
+$c = Get-Content -Path $tmp 
+
+$currentSetting = ""
+
+foreach($s in $c) {
+	if( $s -like "SeServiceLogonRight*") {
+		$x = $s.split("=",[System.StringSplitOptions]::RemoveEmptyEntries)
+		$currentSetting = $x[1].Trim()
+	}
+}
+
+if( $currentSetting -notlike "*$($sidstr)*" ) {
+	Write-Host "Modify Setting ""Logon as a Service""" -ForegroundColor DarkCyan
+	
+	if( [string]::IsNullOrEmpty($currentSetting) ) {
+		$currentSetting = "*$($sidstr)"
+	} else {
+		$currentSetting = "*$($sidstr),$($currentSetting)"
+	}
+	
+	Write-Host "$currentSetting"
+	
+	$outfile = @"
+[Unicode]
+Unicode=yes
+[Version]
+signature="`$CHICAGO`$"
+Revision=1
+[Privilege Rights]
+SeServiceLogonRight = $($currentSetting)
+"@
+
+	$tmp2 = [System.IO.Path]::GetTempFileName()
+	
+	
+	Write-Host "Import new settings to Local Security Policy" -ForegroundColor DarkCyan
+	$outfile | Set-Content -Path $tmp2 -Encoding Unicode -Force
+
+	#notepad.exe $tmp2
+	Push-Location (Split-Path $tmp2)
+	
+	try {
+		secedit.exe /configure /db "secedit.sdb" /cfg "$($tmp2)" /areas USER_RIGHTS 
+		#write-host "secedit.exe /configure /db ""secedit.sdb"" /cfg ""$($tmp2)"" /areas USER_RIGHTS "
+	} finally {	
+		Pop-Location
+	}
+} else {
+	Write-Host "NO ACTIONS REQUIRED! Account already in ""Logon as a Service""" -ForegroundColor DarkCyan
+}
+
+Write-Host "Done." -ForegroundColor DarkCyan
+
+# Configure the sshd service
+cmd /c sc config sshd obj= .\build password= p1votal!

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/setup-ec2config.ps1
----------------------------------------------------------------------
diff --git a/packer/windows/setup-ec2config.ps1 b/packer/windows/setup-ec2config.ps1
new file mode 100644
index 0000000..f90459e
--- /dev/null
+++ b/packer/windows/setup-ec2config.ps1
@@ -0,0 +1,8 @@
+# Enable the system password to be retrieved from the AWS Console after this AMI is built and used to launch code
+$ec2config = [xml] (get-content 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml')
+($ec2config.ec2configurationsettings.plugins.plugin | where {$_.name -eq "Ec2SetPassword"}).state = "Enabled"
+($ec2config.ec2configurationsettings.plugins.plugin | where {$_.name -eq "Ec2DynamicBootVolumeSize"}).state = "Enabled"
+($ec2config.ec2configurationsettings.plugins.plugin | where {$_.name -eq "Ec2HandleUserData"}).state = "Enabled"
+($ec2config.ec2configurationsettings.plugins.plugin | where {$_.name -eq "Ec2SetComputerName"}).state = "Enabled"
+($ec2config.ec2configurationsettings.plugins.plugin | where {$_.name -eq "Ec2EventLog"}).state = "Enabled"
+$ec2config.save("C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml")

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/sshd-recovery.bat
----------------------------------------------------------------------
diff --git a/packer/windows/sshd-recovery.bat b/packer/windows/sshd-recovery.bat
new file mode 100644
index 0000000..43f4c0a
--- /dev/null
+++ b/packer/windows/sshd-recovery.bat
@@ -0,0 +1,4 @@
+net stop ssh-agent /y
+net stop sshd /y
+net start sshd /y
+net start ssh-agent /y

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/packer/windows/winrm.cloud-init
----------------------------------------------------------------------
diff --git a/packer/windows/winrm.cloud-init b/packer/windows/winrm.cloud-init
new file mode 100644
index 0000000..8195a8e
--- /dev/null
+++ b/packer/windows/winrm.cloud-init
@@ -0,0 +1,26 @@
+<powershell>
+$ErrorActionPreference = "Stop";
+
+Set-ExecutionPolicy Unrestricted
+
+write-host "Setting up WinRM"
+
+cmd /c winrm quickconfig -q
+cmd /c winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="8000"}'
+cmd /c winrm set winrm/config/winrs '@{MaxShellsPerUser="5"}'
+cmd /c winrm set winrm/config '@{MaxTimeoutms="1800000"}'
+cmd /c winrm set winrm/config/service '@{AllowUnencrypted="true"}'
+cmd /c winrm set winrm/config/service/auth '@{Basic="true"}'
+
+cmd /c net stop winrm
+# Will restart on reboot
+
+cmd /c netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
+cmd /c netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
+
+cmd /c sc config winrm start= auto
+
+write-host "WinRM ready"
+cmd /c net start winrm
+
+</powershell>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/BUILDING.md
----------------------------------------------------------------------
diff --git a/src/BUILDING.md b/src/BUILDING.md
new file mode 100644
index 0000000..b7d5754
--- /dev/null
+++ b/src/BUILDING.md
@@ -0,0 +1,66 @@
+# Building
+    $ cd <clone>
+    $ mdkir build
+    $ cmake ../src
+    $ cmake --build .
+
+# Platforms Known To Build
+* [Mac OS X](#mac-os-x)
+* [Windows](#windows)
+* [Linux](#linux)
+* [Solaris](#solaris)
+
+# System Requirements
+## All Platforms
+### Required Tools
+* [CMake 4.3](https://cmake.org/) or newer
+* C++11 compiler *(see platform specific requirements)*
+
+### Optional Tools
+* [Doxygen 8.11](http://www.stack.nl/~dimitri/doxygen/download.html) *(If building source documentation)*
+
+## Mac OS X
+* Mac OS X 10.12 (Sierra)
+
+### Required Tools
+* [XCode](https://developer.apple.com/xcode/download/)
+* Xcode command line developer tools
+
+    `$ xcode-select --install` 
+
+### Optional Tools
+* [CMake GUI](https://cmake.org/files/v3.4/cmake-3.4.3-Darwin-x86_64.dmg)
+* [Doxygen GUI](http://ftp.stack.nl/pub/users/dimitri/Doxygen-1.8.11.dmg)
+* [Eclipse CDT 8.8](https://eclipse.org/cdt/) or newer
+
+## Windows
+* Windows 8.1 64-bit
+* Windows 10 64-bit
+* Windows Server 2012 64-bit
+* Windows Server 2012 R2 64-bit
+
+### Required Tools
+* [Visual Studio 2013](https://www.visualstudio.com) or newer
+* [Cygwin](https://www.cygwin.com/)
+
+## Linux
+* RHEL/CentOS 6
+* RHEL/CentOS 7
+* SLES 11
+* SLES 12
+
+### Required Tools
+* [GCC 4.6](https://gcc.gnu.org) or newer
+
+### Optional Tools
+* [Eclipse CDT 8.8](https://eclipse.org/cdt/) or newer
+
+## Solaris
+* Solaris 10 SPARC
+* Solaris 10 x86
+* Solaris 11 SPARC
+* Solaris 11 x86
+
+### Required Tools
+* [Solaris Studion 12.4](http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-141149.html) or newer
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..4df8ccd
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,221 @@
+cmake_minimum_required(VERSION 3.4)
+project(nativeclient)
+
+set(BUILD_BITS 64 CACHE STRING "Build for 64 (default) or 32 bit.")
+
+#TODO cache values
+set(GEMFIRE_PRODUCTNAME "Pivotal GemFire Native Client")
+set(GEMFIRE_BITS "${BUILD_BITS}bit")
+set(GEMFIRE_VERSION "0.0.42" CACHE STRING "GemFire Native Client Version")
+set(GEMFIRE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+  if (CMAKE_SYSTEM_PROCESSOR STREQUAL "sparc")
+    set(GEMFIRE_SYSTEM_NAME "solaris-sparc")
+  else()
+    set(GEMFIRE_SYSTEM_NAME "solaris-x86")
+  endif()
+endif()
+
+set(PRODUCT_VERSION "${GEMFIRE_VERSION}")
+string(REGEX REPLACE "-build" "" PRODUCT_VERSION_DOTTED ${GEMFIRE_VERSION})
+string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" PRODUCT_VERSION_LONG ${GEMFIRE_VERSION})
+string(REGEX MATCH "^[0-9]+\\.[0-9]+" PRODUCT_VERSION_SHORT ${GEMFIRE_VERSION})
+string(REGEX REPLACE "\\." ";" PRODUCT_VERSION_LIST ${PRODUCT_VERSION_DOTTED})
+list(LENGTH PRODUCT_VERSION_LIST _length)
+if (_length LESS 4)
+  foreach(_index RANGE ${_length} 3)
+    list(APPEND PRODUCT_VERSION_LIST 0)
+  endforeach()
+endif()
+list(GET PRODUCT_VERSION_LIST 0 PRODUCT_VERSION_MAJOR)
+list(GET PRODUCT_VERSION_LIST 1 PRODUCT_VERSION_MINOR)
+list(GET PRODUCT_VERSION_LIST 2 PRODUCT_VERSION_PATCH)
+list(GET PRODUCT_VERSION_LIST 3 PRODUCT_VERSION_BUILD)
+
+# Please note that attempts to set CMAKE_INSTALL_PREFIX to a *ROOTED*
+# path here will fail due to the design of CMake according to its
+# development team. Setting it to a relative path appears to work.
+# To override the install location, CMAKE_INSTALL_PREFIX must be
+# specified at the time of generation, e.g.:
+# $ cmake -G Xcode -DCMAKE_INSTALL_PREFIX=/my/favorite/location ../src
+set(CMAKE_INSTALL_PREFIX "nativeclient" CACHE STRING "Install prefix")
+
+set(CMAKE_CONFIGURATION_TYPES Debug Release)
+if (NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE Debug)
+endif()
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+# TODO this doesn't seem to have effect
+set(CMAKE_ECLIPSE_VERSION Mars)
+
+#TODO this check is failing to fail properly on solaris with sun CC 5.10
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(CPACK_PACKAGE_VERSION_MAJOR ${PRODUCT_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${PRODUCT_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${PRODUCT_VERSION_PATCH})
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${GEMFIRE_PRODUCTNAME})
+set(CPACK_PACKAGE_VENDOR "Pivotal")
+set(CPACK_PACKAGE_NAME "pivotal-gemfire-nativeclient")
+set(CPACK_SYSTEM_NAME "${GEMFIRE_SYSTEM_NAME}-${GEMFIRE_BITS}")
+set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PRODUCT_VERSION}-${CPACK_SYSTEM_NAME})
+set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
+set(CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_NAME}")
+#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
+#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
+set(CPACK_GENERATOR TGZ;ZIP)
+
+option(ENABLE_CLANG_TIDY "Enable clang-tidy checks." false)
+if(ENABLE_CLANG_TIDY)
+  find_program(CLANG_TIDY "clang-tidy")
+  if(CLANG_TIDY)
+    set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY})
+    option(ENABLE_CLANG_TIDY_FIX "Enable clang-tidy fix." false)
+    if(ENABLE_CLANG_TIDY)
+      set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} -fix -fix-errors)
+    endif()
+  else()
+    message(SEND_ERROR "clang-tidy enabled but not found.")
+  endif()
+endif()
+
+file(GLOB_RECURSE ALL_CXX_SOURCE_FILES *.[chi]pp *.[chi]xx *.cc *.hh *.ii *.[CHI])
+find_program(CLANG_FORMAT "clang-format")
+if(CLANG_FORMAT)
+  add_custom_target(format COMMAND ${CLANG_FORMAT} -i -style=file -fallback-style=Google ${ALL_CXX_SOURCE_FILES})
+  set_target_properties(format PROPERTIES EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_DEFAULT_BUILD TRUE)
+endif()
+
+include(CPack)
+include(CheckCXXCompilerFlag)
+include(CheckCCompilerFlag)
+
+set(CMAKE_REQUIRED_LIBRARIES -m64)
+check_c_compiler_flag(-m64 CFLAGS_M64_ALLOWED)
+check_cxx_compiler_flag(-m64 CXXFLAGS_M64_ALLOWED)
+set(CMAKE_REQUIRED_LIBRARIES)
+
+check_c_compiler_flag(-mt CFLAGS_mt_ALLOWED)
+
+if (CFLAGS_M64_ALLOWED AND CXXFLAGS_M64_ALLOWED)
+  set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -m64)
+  add_compile_options(-m64)
+#TODO cmake find better way to set linker flags
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
+  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m64")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
+endif()
+
+if (CFLAGS_mt_ALLOWED)
+  set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -mt)
+  add_compile_options(-mt)
+endif()
+
+#TODO remove this debugging for NMake
+set(CMAKE_VERBOSE_MAKEFILE 0)
+
+add_library(c++11 INTERFACE)
+
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
+  # Force linker to error on undefined symbols in shared libraries
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z defs")
+  # TODO cmake find a better way to set runtime libraries
+  # C++11 requires these libraries, treat -std=c++11 as library
+  #TODO look into CMAKE_CXX_STANDARD_LIBRARIES
+  target_link_libraries(c++11 INTERFACE -std=c++11 stdc++ gcc_s CrunG3 c)
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+endif()
+if(MSVC)
+    # TODO error on warnings
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+  set(BUILD_CLI 1)
+  set(STRONG_NAME_KEY "" CACHE FILEPATH "Strong Name Key File")
+  if(EXISTS "${STRONG_NAME_KEY}")
+    set(SHARED_LINKER_FLAGS_STRONG_KEY "/keyfile:${STRONG_NAME_KEY}")
+    execute_process(COMMAND sn -p ${STRONG_NAME_KEY} ${CMAKE_CURRENT_BINARY_DIR}/public.snk)
+    execute_process(COMMAND sn -tp ${CMAKE_CURRENT_BINARY_DIR}/public.snk OUTPUT_VARIABLE STRONG_NAME_PUBLIC_KEY)
+    string(REPLACE "\n" "" STRONG_NAME_PUBLIC_KEY ${STRONG_NAME_PUBLIC_KEY})
+    string(REGEX REPLACE ".*sha1\\):([a-f0-9]+).*" "\\1" STRONG_NAME_PUBLIC_KEY ${STRONG_NAME_PUBLIC_KEY})
+  endif()
+endif()
+
+find_package(Java 1.8.0.60 REQUIRED COMPONENTS Development)
+
+if ("${CMAKE_AR}" STREQUAL "CMAKE_AR-NOTFOUND")
+  message(FATAL_ERROR "Utility ar not found.")
+endif()
+
+if (WIN32 OR ${CMAKE_GENERATOR} STREQUAL "Xcode")
+  set(CMAKE_USES_BUILDTYPE TRUE)
+  set ( _DEBUG_OR_RELEASE $<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>)
+else()
+  set(CMAKE_USES_BUILDTYPE FALSE)
+  set ( _DEBUG_OR_RELEASE )
+endif()
+
+# Since RPATH embeds path information into the executables that
+# may not be valid in all execution contexts, do not use RPATH.
+set(CMAKE_SKIP_RPATH TRUE)
+set(CMAKE_MACOSX_RPATH FALSE)
+
+# Default to only showing output on failure for unit tests but allow
+# overriding with the CTEST_UNITTEST_VERBOSITY environment variable.
+set(CTEST_UNITTEST_VERBOSITY --output-on-failure)
+if(DEFINED ENV{CTEST_UNITTEST_VERBOSITY})
+    set(CTEST_UNITTEST_VERBOSITY $ENV{CTEST_UNITTEST_VERBOSITY})
+endif()
+
+set(GEMFIRE_HOME "" CACHE PATH "Path to GemFire production installation.")
+
+add_custom_target(client-libraries)
+
+add_custom_target(unit-tests)
+add_custom_target(run-unit-tests)
+add_dependencies(run-unit-tests unit-tests)
+set_target_properties(run-unit-tests PROPERTIES
+    EXCLUDE_FROM_ALL TRUE
+    EXCLUDE_FROM_DEFAULT_BUILD TRUE
+)
+
+add_custom_target(integration-tests)
+add_custom_target(run-integration-tests)
+add_dependencies(run-integration-tests integration-tests)
+set_target_properties(run-integration-tests PROPERTIES
+    EXCLUDE_FROM_ALL TRUE
+    EXCLUDE_FROM_DEFAULT_BUILD TRUE
+)
+
+add_subdirectory(dependencies)
+add_subdirectory(cppcache)
+add_subdirectory(cryptoimpl)
+add_subdirectory(dhimpl)
+add_subdirectory(sqliteimpl)
+add_subdirectory(gfcpp)
+add_subdirectory(pdxautoserializer)
+add_subdirectory(tests)
+add_subdirectory(templates/security)
+add_subdirectory(docs)
+if (${BUILD_CLI})
+  add_subdirectory(clicache)
+  add_subdirectory(plugins/SQLiteCLI)
+endif()
+
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/quickstart/ DESTINATION SampleCode/quickstart)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cppcache/integration-test/keystore/ DESTINATION SampleCode/quickstart/keystore)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/xsds/ DESTINATION xsds)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/defaultSystem/ DESTINATION defaultSystem)
+
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/templates/ DESTINATION templates
+  PATTERN "templates/security/CMakeLists.txt" EXCLUDE
+  PATTERN "templates/security/CMakeLists.txt.forInstall" EXCLUDE)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/security/CMakeLists.txt.forInstall RENAME CMakeLists.txt DESTINATION templates/security)
+
+install(FILES Pivotal_EULA.txt RENAME EULA.txt DESTINATION .)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests/javaobject/javaobject.jar DESTINATION SampleCode/quickstart/lib)

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/FindNativeClient.cmake
----------------------------------------------------------------------
diff --git a/src/FindNativeClient.cmake b/src/FindNativeClient.cmake
new file mode 100755
index 0000000..9f87997
--- /dev/null
+++ b/src/FindNativeClient.cmake
@@ -0,0 +1,277 @@
+#.rst:
+# FindJava
+# --------
+#
+# Find Java
+#
+# This module finds if Java is installed and determines where the
+# include files and libraries are.  The caller may set variable JAVA_HOME
+# to specify a Java installation prefix explicitly.
+#
+#
+# Specify one or more of the following components as you call this find module. See example below.
+#
+# ::
+#
+#   Runtime     = User just want to execute some Java byte-compiled
+#   Development = Development tools (java, javac, javah and javadoc), includes Runtime component
+#   IdlJ        = idl compiler for Java
+#   JarSigner   = signer tool for jar
+#
+#
+# This module sets the following result variables:
+#
+# ::
+#
+#   Java_JAVA_EXECUTABLE      = the full path to the Java runtime
+#   Java_JAVAC_EXECUTABLE     = the full path to the Java compiler
+#   Java_JAVAH_EXECUTABLE     = the full path to the Java header generator
+#   Java_JAVADOC_EXECUTABLE   = the full path to the Java documention generator
+#   Java_IDLJ_EXECUTABLE      = the full path to the Java idl compiler
+#   Java_JAR_EXECUTABLE       = the full path to the Java archiver
+#   Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer
+#   Java_VERSION_STRING       = Version of java found, eg. 1.6.0_12
+#   Java_VERSION_MAJOR        = The major version of the package found.
+#   Java_VERSION_MINOR        = The minor version of the package found.
+#   Java_VERSION_PATCH        = The patch version of the package found.
+#   Java_VERSION_TWEAK        = The tweak version of the package found (after '_')
+#   Java_VERSION              = This is set to: $major.$minor.$patch(.$tweak)
+#
+#
+#
+# The minimum required version of Java can be specified using the
+# standard CMake syntax, e.g.  find_package(Java 1.5)
+#
+# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to
+# be identical.  For example some java version may return:
+# Java_VERSION_STRING = 1.5.0_17 and Java_VERSION = 1.5.0.17
+#
+# another example is the Java OEM, with: Java_VERSION_STRING = 1.6.0-oem
+# and Java_VERSION = 1.6.0
+#
+# For these components the following variables are set:
+#
+# ::
+#
+#   Java_FOUND                    - TRUE if all components are found.
+#   Java_INCLUDE_DIRS             - Full paths to all include dirs.
+#   Java_LIBRARIES                - Full paths to all libraries.
+#   Java_<component>_FOUND        - TRUE if <component> is found.
+#
+#
+#
+# Example Usages:
+#
+# ::
+#
+#   find_package(Java)
+#   find_package(Java COMPONENTS Runtime)
+#   find_package(Java COMPONENTS Development)
+
+#=============================================================================
+# Copyright 2002-2009 Kitware, Inc.
+# Copyright 2009-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
+
+# The HINTS option should only be used for values computed from the system.
+set(_JAVA_HINTS)
+if(_JAVA_HOME)
+  list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin)
+endif()
+list(APPEND _JAVA_HINTS
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
+  )
+# Hard-coded guesses should still go in PATHS. This ensures that the user
+# environment can always override hard guesses.
+set(_JAVA_PATHS
+  /usr/lib/java/bin
+  /usr/share/java/bin
+  /usr/local/java/bin
+  /usr/local/java/share/bin
+  /usr/java/j2sdk1.4.2_04
+  /usr/lib/j2sdk1.4-sun/bin
+  /usr/java/j2sdk1.4.2_09/bin
+  /usr/lib/j2sdk1.5-sun/bin
+  /opt/sun-jdk-1.5.0.04/bin
+  /usr/local/jdk-1.7.0/bin
+  /usr/local/jdk-1.6.0/bin
+  )
+find_program(Java_JAVA_EXECUTABLE
+  NAMES java
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+if(Java_JAVA_EXECUTABLE)
+    execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -version
+      RESULT_VARIABLE res
+      OUTPUT_VARIABLE var
+      ERROR_VARIABLE var # sun-java output to stderr
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      ERROR_STRIP_TRAILING_WHITESPACE)
+    if( res )
+      if(var MATCHES "No Java runtime present, requesting install")
+        set_property(CACHE Java_JAVA_EXECUTABLE
+          PROPERTY VALUE "Java_JAVA_EXECUTABLE-NOTFOUND")
+      elseif(${Java_FIND_REQUIRED})
+        message( FATAL_ERROR "Error executing java -version" )
+      else()
+        message( STATUS "Warning, could not run java -version")
+      endif()
+    else()
+      # extract major/minor version and patch level from "java -version" output
+      # Tested on linux using
+      # 1. Sun / Sun OEM
+      # 2. OpenJDK 1.6
+      # 3. GCJ 1.5
+      # 4. Kaffe 1.4.2
+      # 5. OpenJDK 1.7.x on OpenBSD
+      if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"")
+        # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+      elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
+        # Kaffe style
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+      elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+.*)\"")
+        # OpenJDK ver 1.7.x on OpenBSD
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+      else()
+        if(NOT Java_FIND_QUIETLY)
+          message(WARNING "regex not supported: ${var}. Please report")
+        endif()
+      endif()
+      string( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" )
+      string( REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_MINOR "${Java_VERSION_STRING}" )
+      string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_PATCH "${Java_VERSION_STRING}" )
+      # warning tweak version can be empty:
+      string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+[_\\.]?([0-9]*).*$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" )
+      if( Java_VERSION_TWEAK STREQUAL "" ) # check case where tweak is not defined
+        set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH})
+      else()
+        set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK})
+      endif()
+    endif()
+
+endif()
+
+
+find_program(Java_JAR_EXECUTABLE
+  NAMES jar
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+find_program(Java_JAVAC_EXECUTABLE
+  NAMES javac
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+find_program(Java_JAVAH_EXECUTABLE
+  NAMES javah
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+find_program(Java_JAVADOC_EXECUTABLE
+  NAMES javadoc
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+find_program(Java_IDLJ_EXECUTABLE
+  NAMES idlj
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+find_program(Java_JARSIGNER_EXECUTABLE
+  NAMES jarsigner
+  HINTS ${_JAVA_HINTS}
+  PATHS ${_JAVA_PATHS}
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+if(Java_FIND_COMPONENTS)
+  set(_JAVA_REQUIRED_VARS)
+  foreach(component ${Java_FIND_COMPONENTS})
+    # User just want to execute some Java byte-compiled
+    If(component STREQUAL "Runtime")
+      list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE)
+      if(Java_JAVA_EXECUTABLE)
+        set(Java_Runtime_FOUND TRUE)
+      endif()
+    elseif(component STREQUAL "Development")
+      list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE
+                                      Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
+      if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
+          AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
+        set(Java_Development_FOUND TRUE)
+      endif()
+    elseif(component STREQUAL "IdlJ")
+      list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE)
+      if(Java_IdlJ_EXECUTABLE)
+        set(Java_Extra_FOUND TRUE)
+      endif()
+    elseif(component STREQUAL "JarSigner")
+      list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE)
+      if(Java_IDLJ_EXECUTABLE)
+        set(Java_JarSigner_FOUND TRUE)
+      endif()
+    else()
+      message(FATAL_ERROR "Comp: ${component} is not handled")
+    endif()
+  endforeach()
+  list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS)
+  find_package_handle_standard_args(Java
+    REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS
+    VERSION_VAR Java_VERSION
+    )
+  if(Java_FOUND)
+    foreach(component ${Java_FIND_COMPONENTS})
+      set(Java_${component}_FOUND TRUE)
+    endforeach()
+  endif()
+else()
+  # Check for Development
+  find_package_handle_standard_args(Java
+    REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
+                  Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
+    VERSION_VAR Java_VERSION
+    )
+endif()
+
+
+mark_as_advanced(
+  Java_JAVA_EXECUTABLE
+  Java_JAR_EXECUTABLE
+  Java_JAVAC_EXECUTABLE
+  Java_JAVAH_EXECUTABLE
+  Java_JAVADOC_EXECUTABLE
+  Java_IDLJ_EXECUTABLE
+  Java_JARSIGNER_EXECUTABLE
+  )
+
+# LEGACY
+set(JAVA_RUNTIME ${Java_JAVA_EXECUTABLE})
+set(JAVA_ARCHIVE ${Java_JAR_EXECUTABLE})
+set(JAVA_COMPILE ${Java_JAVAC_EXECUTABLE})
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/FindNativeClientCPPCache.cmake
----------------------------------------------------------------------
diff --git a/src/FindNativeClientCPPCache.cmake b/src/FindNativeClientCPPCache.cmake
new file mode 100755
index 0000000..6a621fc
--- /dev/null
+++ b/src/FindNativeClientCPPCache.cmake
@@ -0,0 +1,68 @@
+#.rst:
+# FindNativeClientCPPCache
+# ------------------------
+#
+# Try to find the NativeClient cppcache library
+#
+# Once done this will define
+#
+# ::
+#
+#   NATIVECLIENT_CPPCACHE_FOUND - true when cmake has found the NativeClient CPPCache library
+#   NATIVECLIENT_CPPCACHE_INCLUDE_DIR - The NativeClient include directory
+#   NATIVECLIENT_CPPCACHE_LIBRARIES - The libraries needed to use NativeClient CPPCache library
+#   NATIVECLIENT_CPPCACH_DEFINITIONS - Compiler switches required for using NativeClient CPPCache library
+#   NATIVECLIENT_CPPCACH_VERSION_STRING - the version of NativeClient CPPCache library found
+
+#=============================================================================
+# Copyright 2006-2009 Kitware, Inc.
+# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (TODO: To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
+   HINTS
+   ${PC_LIBXML_INCLUDEDIR}
+   ${PC_LIBXML_INCLUDE_DIRS}
+   PATH_SUFFIXES libxml2
+   )
+
+find_library(LIBXML2_LIBRARIES NAMES xml2 libxml2
+   HINTS
+   ${PC_LIBXML_LIBDIR}
+   ${PC_LIBXML_LIBRARY_DIRS}
+   )
+
+find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint)
+
+set( NATIVECLIENT_CPPCACHE_VERSION_STRING "9.0" )
+set( NATIVECLIENT_CPPCACHE_FOUND "YES" )
+set( NATIVECLIENT_CPPCACHE_INCLUDE_DIR  ${CMAKE_CURRENT_BINARY_DIRECTORY}/include ) # TODO: Replace with install directory
+set( NATIVECLIENT_CPPCACHE_LIBRARIES  ${GTK_gtk_LIBRARY}
+                    ${GTK_gdk_LIBRARY}
+                    ${GTK_glib_LIBRARY} )
+elseif(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h")
+    file(STRINGS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str
+         REGEX "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"")
+
+    string(REGEX REPLACE "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
+           LIBXML2_VERSION_STRING "${libxml2_version_str}")
+    unset(libxml2_version_str)
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
+# all listed variables are TRUE
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2
+                                  REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR
+                                  VERSION_VAR LIBXML2_VERSION_STRING)
+
+mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE)

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/README
----------------------------------------------------------------------
diff --git a/src/cclient/README b/src/cclient/README
new file mode 100644
index 0000000..388e268
--- /dev/null
+++ b/src/cclient/README
@@ -0,0 +1,34 @@
+Operating instructions:
+This is first cut of C client for Gemfire cache. 
+Source code is in src directory. There is a sample programe in sample
+directory, which demonstrates basic usage of the library. There is a
+Makefile provided which builds the library, as well as sample program.
+To run the sample program, execute runit.sh in sample directory.
+Befure executing runit.sh GEMFIRE and GFCCLIENT environment variables 
+have to be set. GEMFIRE should contain path to Gemfire installation 
+and GFCCLIENT should contain path to C client dist library (which is
+created while building using Makefile).
+
+NOTES:
+1. gf_connect function returns a CONTEXT pointer which should be passed
+    while doing any operation. 
+2. A CONTEXT pointer should not be used to perform multiple operations
+    simultaneously
+3. A program can maintain a pool of CONTEXT pointers, and any thread can
+    borrow the pointer and return it when done.
+4. There is a gf_ping function in the API. Idle timeout at the server is 
+    60 seconds certain interval, otherwise it closes the socket. A program
+    should call gf_ping function periodically in a separate thread.
+2. gf_disconnect frees up the CONTEXT pointer
+
+
+Troubleshooting:
+Write now, client does not have any logging. For troubleshooting,
+server logs have to be analysed. To enable all logs in the server,
+'log-level=all' has to be passed as command line arguments while 
+starting the server. In samples directory, 'runit.sh' contains the
+command for starting the server with all logging enabled.
+
+Contact information:
+Ankur Srivastava <ankurs@vmware.com>
+Vishal Rao <raov@vmware.com>

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/sample/runit.sh
----------------------------------------------------------------------
diff --git a/src/cclient/sample/runit.sh b/src/cclient/sample/runit.sh
new file mode 100755
index 0000000..45b2c79
--- /dev/null
+++ b/src/cclient/sample/runit.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ -z ${GFCCLIENT:-} ]; then
+    echo GFCCLIENT is not set.
+    exit 1
+fi
+if [ -z ${GEMFIRE:-} ]; then
+    echo GEMFIRE is not set.
+    exit 1
+fi
+
+
+export LD_LIBRARY_PATH=$GFCCLIENT:$LD_LIBRARY_PATH
+$GEMFIRE/bin/cacheserver start cache-xml-file=sampleserver.xml log-level=all
+./sample
+$GEMFIRE/bin/cacheserver stop
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/sample/sample.c
----------------------------------------------------------------------
diff --git a/src/cclient/sample/sample.c b/src/cclient/sample/sample.c
new file mode 100644
index 0000000..7ae54a7
--- /dev/null
+++ b/src/cclient/sample/sample.c
@@ -0,0 +1,85 @@
+#include <gf_client.h>
+#include <stdio.h>
+
+void printByteArray(int8_t* arr, int32_t len)
+{
+    int32_t i = 0;
+    for(i = 0; i < len; i++)
+    {
+        printf("%d", arr[i]);
+    }
+}
+
+
+int main(int argc, char** argv)
+{
+    int resultcode = NO_ERROR;
+    char* key = "key";
+    int8_t data[] = {1,2,3,4};
+    int8_t returnData[4];
+    CONTEXT* context = gf_connect("localhost", "40404", &resultcode);
+    if(resultcode == NO_ERROR)
+    {
+        printf("Connection successful.\n");
+        if(context != NULL) {
+            resultcode = NO_ERROR;
+            printf("Sending ping message... ");
+            gf_ping(context, &resultcode);
+            if(resultcode == NO_ERROR)
+            {
+                printf("successful.\n");
+            } else {
+                printf("failed. Error code: %d\n", resultcode);
+            }
+
+            resultcode = NO_ERROR;
+            printf("Sending put with key=%s, and value=", key);
+            printByteArray(data, 4);
+            printf("... ");
+            gf_put(context, key, data, 4, &resultcode);
+            if(resultcode == NO_ERROR)
+            {
+                printf("successful.\n");
+            } else {
+                printf("failed. Error code: %d\n", resultcode);
+            }
+
+            resultcode = NO_ERROR;
+            printf("Sending get message with key=%s... ", key);
+            gf_get(context, "key",returnData, 1024, &resultcode);
+            if(resultcode == NO_ERROR)
+            {
+                printf("successful. got '");
+                printByteArray(returnData, 4);
+                printf("'.\n");
+            } else {
+                printf("failed. Error code: %d\n", resultcode);
+            }
+
+            resultcode = NO_ERROR;
+            printf("Sending destroy with key=%s... ", key);
+            gf_destroy(context, "key", &resultcode);
+            if(resultcode == NO_ERROR)
+            {
+                printf("successful.\n");
+            } else {
+                printf("failed. Error code: %d\n", resultcode);
+            }
+
+            resultcode = NO_ERROR;
+            printf("disconnecting... ");
+            gf_disconnect(context, &resultcode);
+            if(resultcode == NO_ERROR)
+            {
+                printf("successful.\n");
+            } else {
+                printf("failed. Error code: %d\n", resultcode);
+            }
+        }
+    } else {
+        printf("Connection failure. Error Code: %d\n", resultcode);
+    }
+
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/sample/sampleserver.xml
----------------------------------------------------------------------
diff --git a/src/cclient/sample/sampleserver.xml b/src/cclient/sample/sampleserver.xml
new file mode 100644
index 0000000..a823665
--- /dev/null
+++ b/src/cclient/sample/sampleserver.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<!-- serverBasicOperations.xml
+     Configures a server to for clients at port 40404.
+-->
+
+<cache xmlns="http://geode.apache.org/schema/cache"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+       version="1.0">
+  <cache-server port="40404"/>
+  <region name="ROOT-REGION">
+    <region-attributes scope="distributed-no-ack" data-policy="replicate"/>
+  </region>
+</cache>

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/src/data_io.c
----------------------------------------------------------------------
diff --git a/src/cclient/src/data_io.c b/src/cclient/src/data_io.c
new file mode 100644
index 0000000..59d48bc
--- /dev/null
+++ b/src/cclient/src/data_io.c
@@ -0,0 +1,312 @@
+#include "data_io.h"
+#include <stdio.h>
+/**
+ * Write an unsigned byte to the <code>DataOutput</code>.
+ *
+ * @param value the unsigned byte to be written
+ */
+inline void writeUnsigned(Buffer* buf, uint8_t value)
+{
+    ensureCapacity(buf,1);
+    writeNoCheck(buf, value);
+}
+
+/**
+ * Write a signed byte to the <code>DataOutput</code>.
+ *
+ * @param value the signed byte to be written
+ */
+inline void writeByte(Buffer* buf, int8_t value)
+{
+    writeUnsigned(buf, (uint8_t)value);
+}
+
+/**
+ * Read a signed byte from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the signed byte read from stream
+ */
+inline void readByte(Buffer* buf, int8_t* value )
+{
+    //checkBufferSize(1);
+    *value = *(buf->m_buf++);
+}
+
+/**
+ *    * Read a 16-bit signed integer from the <code>DataInput</code>.
+ *       *
+ *          * @param value output parameter to hold the 16-bit signed integer
+ *             *   read from stream
+ *                */
+inline void readShort(Buffer* buf, int16_t* value )
+{
+//    checkBufferSize(2);
+    readUnsignedShort(buf, (uint16_t*)value );
+}
+
+
+/**
+ *    * Read a 16-bit unsigned integer from the <code>DataInput</code>.
+ *       *
+ *          * @param value output parameter to hold the 16-bit unsigned integer
+ *             *   read from stream
+ *                */
+inline void readUnsignedShort(Buffer* buf, uint16_t* value )
+{
+//    checkBufferSize(2);
+    uint16_t tmp = *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    *value = tmp;
+}
+
+
+/**
+ * Read a 32-bit signed integer from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the 32-bit signed integer
+ *   read from stream
+ */
+inline void readInt(Buffer* buf, int32_t* value )
+{
+    //checkBufferSize(4);
+    readUnsignedInt(buf, (uint32_t*)value );
+}
+
+
+/**
+ * Read a 32-bit unsigned integer from the <code>DataInput</code>.
+ *
+ * @param value output parameter to hold the 32-bit unsigned integer
+ *   read from stream
+ */
+inline void readUnsignedInt(Buffer* buf, uint32_t* value )
+{
+    //checkBufferSize(4);
+    uint32_t tmp = *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    tmp = (tmp << 8) | *(buf->m_buf++);
+    *value = tmp;
+}
+
+
+
+
+/**
+ * Write an array of unsigned bytes to the <code>DataOutput</code>.
+ *
+ * @param value the array of unsigned bytes to be written
+ * @param len the number of bytes from the start of array to be written
+ */
+inline void writeUnsignedBytes(Buffer* buf,  const uint8_t* bytes, int32_t len )
+{
+    if (len >= 0) {
+        ensureCapacity(buf, len + 5 );
+        writeArrayLen(buf,  bytes==NULL ? 0 : len ); // length of bytes...
+        if ( len > 0 && bytes != NULL) {
+            memcpy( buf->m_buf, bytes, len );
+            buf->m_buf += len;
+        }
+    } else {
+        writeByte(buf, (int8_t) -1 );
+    }
+}
+
+/**
+ * Write an array of signed bytes to the <code>DataOutput</code>.
+ *
+ * @param value the array of signed bytes to be written
+ * @param len the number of bytes from the start of array to be written
+ */
+inline void writeBytes(Buffer* buf,  const int8_t* bytes, int32_t len )
+{
+   // printf("bytes length: %d\n", len);
+    writeUnsignedBytes(buf, (const uint8_t*)bytes, len );
+}
+/**
+ * Write a 32-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 32-bit unsigned integer value to be written
+ */
+inline void writeUnsignedInt( Buffer* buf,uint32_t value )
+{
+    ensureCapacity(buf, 4 );
+    *(buf->m_buf++) = (uint8_t)(value >> 24);
+    *(buf->m_buf++) = (uint8_t)(value >> 16);
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 32-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 32-bit signed integer value to be written
+ */
+inline void writeInt(Buffer* buf,  int32_t value )
+{
+    writeUnsignedInt(buf, (uint32_t)value );
+}
+
+/**
+ * Write a 64-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 64-bit unsigned integer value to be written
+ */
+inline void writeUnsignedLong( Buffer* buf,uint64_t value )
+{
+    ensureCapacity(buf, 8 );
+    *(buf->m_buf++) = (uint8_t)(value >> 56);
+    *(buf->m_buf++) = (uint8_t)(value >> 48);
+    *(buf->m_buf++) = (uint8_t)(value >> 40);
+    *(buf->m_buf++) = (uint8_t)(value >> 32);
+    *(buf->m_buf++) = (uint8_t)(value >> 24);
+    *(buf->m_buf++) = (uint8_t)(value >> 16);
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 64-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 64-bit signed integer value to be written
+ */
+inline void writeLong(Buffer* buf,  int64_t value )
+{
+    writeUnsignedLong(buf, (uint64_t)value );
+}
+
+/**
+ * Write a 16-bit unsigned integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 16-bit unsigned integer value to be written
+ */
+inline void writeUnsignedShort( Buffer* buf,uint16_t value )
+{
+    ensureCapacity(buf, 2 );
+    *(buf->m_buf++) = (uint8_t)(value >> 8);
+    *(buf->m_buf++) = (uint8_t)value;
+}
+
+/**
+ * Write a 16-bit signed integer value to the <code>DataOutput</code>.
+ *
+ * @param value the 16-bit signed integer value to be written
+ */
+inline void writeShort(Buffer* buf,  int16_t value )
+{
+    writeUnsignedShort(buf, (uint16_t)value );
+}
+
+/**
+ * Write a 32-bit signed integer array length value to the
+ * <code>DataOutput</code> in a manner compatible with java server's
+ * <code>DataSerializer.writeArrayLength</code>.
+ *
+ * @param value the 32-bit signed integer array length to be written
+ */
+inline void writeArrayLen(Buffer* buf,  int32_t len )
+{
+    if (len == -1) {
+        writeByte(buf, (int8_t) -1);
+    } else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF)
+        writeUnsigned(buf, (uint8_t)len);
+    } else if (len <= 0xFFFF) {
+        writeByte(buf, (int8_t) -2);
+        writeUnsignedShort(buf, (uint16_t)len);
+    } else {
+        writeByte(buf, (int8_t) -3);
+        writeInt(buf, len);
+    }
+}
+
+/**
+ * Advance the buffer cursor by the given offset.
+ *
+ * @param offset the offset by which to advance the cursor
+ */
+void advanceCursor(Buffer* buf, uint32_t offset)
+{
+    buf->m_buf += offset;
+}
+
+/**
+ * Rewind the buffer cursor by the given offset.
+ *
+ * @param offset the offset by which to rewind the cursor
+ */
+void rewindCursor(Buffer* buf, uint32_t offset)
+{
+    buf->m_buf -= offset;
+}
+
+/**
+ * Get the length of current data in the internal buffer of
+ * <code>DataOutput</code>.
+ */
+inline uint32_t getBufferLength(Buffer* buf) {
+    return (uint32_t)( buf->m_buf - buf->m_bytes );
+}
+
+inline uint8_t* getBuffer(Buffer* buf)
+{
+    return buf->m_bytes;
+}
+
+inline uint8_t* getCursor(Buffer* buf) {
+    return buf->m_buf;
+}
+
+// make sure there is room left for the requested size item.
+inline void ensureCapacity(Buffer* buf,  uint32_t size )
+{
+    uint32_t offset = (uint32_t)( buf->m_buf - buf->m_bytes );
+    if ( (buf->m_size - offset) < size ) {
+        uint32_t newSize = buf->m_size * 2 + (8192 * (size / 8192));
+        buf->m_size = newSize;
+        GF_RESIZE( buf->m_bytes, uint8_t, buf->m_size );
+        buf->m_buf = buf->m_bytes + offset;
+    }
+}
+
+inline void writeNoCheck(Buffer* buf, uint8_t value)
+{
+    //uint32_t offset = (uint32_t)( buf->m_buf - buf->m_bytes );
+    //printf("%d:%d\n",offset, buf->m_size);
+    *(buf->m_buf++) = value;
+}
+
+
+inline void initBuf(Buffer* buf)
+{
+    GF_ALLOC( buf->m_bytes, uint8_t, 8192 );
+    buf->m_buf = buf->m_bytes;
+    buf->m_size = 8192;
+}
+
+inline void clearBuf(Buffer* buf)
+{
+    GF_FREE(buf->m_bytes);
+    buf->m_bytes = NULL;
+    buf->m_buf = NULL;
+    buf->m_size = 0;
+}
+
+inline void writeASCII(Buffer* buf, const char* value)
+{
+    if ( value != NULL ) {
+      uint32_t length = (uint32_t)strlen( value );
+      uint16_t len = (uint16_t)( length > 0xFFFF ? 0xFFFF : length );
+      writeUnsignedShort(buf, len);
+      writeBytesOnly(buf, (int8_t*)value, len ); // K64
+    } else {
+      writeShort(buf, (uint16_t)0);
+    }
+}
+
+inline void writeBytesOnly(Buffer* buf,  const int8_t* bytes, int32_t len)
+{
+    ensureCapacity(buf, len);
+    memcpy(buf->m_buf, bytes, len);
+    buf->m_buf += len;
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/cclient/src/data_io.h
----------------------------------------------------------------------
diff --git a/src/cclient/src/data_io.h b/src/cclient/src/data_io.h
new file mode 100644
index 0000000..0e07320
--- /dev/null
+++ b/src/cclient/src/data_io.h
@@ -0,0 +1,80 @@
+//=========================================================================
+// Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+// This product is protected by U.S. and international copyright
+// and intellectual property laws. Pivotal products are covered by
+// more patents listed at http://www.pivotal.io/patents.
+//========================================================================
+
+#ifndef __C_GEMFIRE_DATAOUTPUT_H__
+#define __C_GEMFIRE_DATAOUTPUT_H__
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+/**
+ * @file
+ */
+
+/**
+ * C style memory allocation that throws OutOfMemoryException
+ * if it fails
+ */
+#define GF_ALLOC(v,t,s) \
+{ \
+    v = (t*)malloc((s) * sizeof(t)); \
+}
+
+/**
+ * C style memory re-allocation that throws OutOfMemoryException
+ * if it fails
+ */
+#define GF_RESIZE(v,t,s) \
+{ \
+    v = (t*)realloc(v, (s) * sizeof(t)); \
+}
+
+#define GF_FREE(v) free(v)
+
+typedef struct {
+  // memory m_buffer to encode to.
+  uint8_t* m_bytes;
+  // cursor.
+  uint8_t* m_buf;
+  // size of m_bytes.
+  uint32_t m_size;
+} Buffer;
+
+inline void writeUnsigned(Buffer* buf, uint8_t value);
+inline void writeByte(Buffer* buf, int8_t value);
+inline void writeUnsignedBytes(Buffer* buf,  const uint8_t* bytes, int32_t len );
+inline void writeBytes(Buffer* buf,  const int8_t* bytes, int32_t len );
+inline void writeBytesOnly(Buffer* buf,  const int8_t* bytes, int32_t len );
+inline void writeUnsignedInt( Buffer* buf,uint32_t value );
+inline void writeInt(Buffer* buf,  int32_t value );
+inline void writeUnsignedLong( Buffer* buf,uint64_t value );
+inline void writeLong(Buffer* buf,  int64_t value );
+inline void writeUnsignedShort( Buffer* buf,uint16_t value );
+inline void writeShort(Buffer* buf,  int16_t value );
+inline void writeArrayLen(Buffer* buf,  int32_t len );
+inline void writeASCII(Buffer* buf, const char* value);
+inline void writeNoCheck(Buffer* buf, uint8_t value);
+
+inline void readByte(Buffer* buf, int8_t* value );
+inline void readShort(Buffer* buf, int16_t* value );
+inline void readUnsignedShort(Buffer* buf, uint16_t* value );
+inline void readInt(Buffer* buf, int32_t* value );
+inline void readUnsignedInt(Buffer* buf, uint32_t* value );
+
+void advanceCursor(Buffer* buf, uint32_t offset);
+void rewindCursor(Buffer* buf, uint32_t offset);
+
+inline void initBuf(Buffer* buf);
+inline void clearBuf(Buffer* buf);
+inline uint32_t getBufferLength(Buffer* buf) ;
+inline uint8_t* getBuffer(Buffer* buf) ;
+inline uint8_t* getCursor(Buffer* buf) ;
+
+inline void ensureCapacity(Buffer* buf,  uint32_t size );
+
+#endif // __C_GEMFIRE_DATAOUTPUT_H__


Mime
View raw message