Skip to content

Commit

Permalink
Merge pull request #2 from MichaelGG/vs2012_and_cleanup
Browse files Browse the repository at this point in the history
Vs2012 and cleanup
  • Loading branch information
aweisberg committed Mar 7, 2013
2 parents 02e5cb8 + 05b1165 commit 43b688f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 91 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.suo
[Bb]in
[Dd]ebug/
[Rr]elease/
*.docstates
ReleaseBuild/
77 changes: 2 additions & 75 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,5 @@ The VoltDB client library implements the native VoltDB wire
protocol. You can use the library to connect to a VoltDB cluster,
invoke stored procedures and read responses.

The Using VoltDB Guide explains how to use the CPP library in the
chapter 12.1.2: Writing VoltDB Client Applications in C++.

Binaries for 64-bit Linux and 64-bit OSX 10.5+ are provided. The
linking instructions below apply to the Linux binaries.


== Linking against libvoltdb.a

The following command will compile and link an example client
(clientvoter.cpp) libvoltdb.a.

Directory structure for this example:

./clientvoter.cpp # Example client
./voltdb/include/ # Directory containing client library headers
./voltdb/lib # Directory containing client library archive

g++ -lrt -I./voltdb/usr/include/ \
-D__STDC_LIMIT_MACROS \
-DBOOST_SP_DISABLE_THREADS \
clientvoter.cpp \
./voltdb/lib/libvoltcpp.a \
-o clientvoter

==== Example clientvoter.cpp

/*
This very simple example demonstrates a few basic concepts.
This example executes against the 'voter' example included
in the voltdb distribution.

The "Using VoltDB Guide" includes more complete information.
*/

#include "Client.h"
#include "Parameter.hpp"
#include "ParameterSet.hpp"
#include "Row.hpp"
#include "Table.h"
#include "TableIterator.h"
#include "WireType.h"

#include <vector>

using namespace std;

int main(int argc, char** argv) {

// instantiate a voltdb::Client instance
voltdb::Client client = voltdb::Client::create();
client.createConnection("localhost");

// create a procedure instance for the Initialize procedure
vector<voltdb::Parameter> initParamTypes(2);
initParamTypes[0] = voltdb::Parameter(voltdb::WIRE_TYPE_INTEGER);
initParamTypes[1] = voltdb::Parameter(voltdb::WIRE_TYPE_STRING);
voltdb::Procedure initialize("Initialize", initParamTypes);
voltdb::ParameterSet *initParams = initialize.params();

// invoke the Initialize procedure
int64_t maxContestant = 4;
string contestantNames = "Edwina Burnam,Tabatha Gehling,Kelly Clauss,Jessie Alloway";
initParams->addInt32(maxContestant);
initParams->addString(contestantNames);
voltdb::InvocationResponse initResponse = client.invoke(initialize);

if (initResponse.failure()) {
cout << "Initialization failed. " << initResponse.toString() << endl;
return -1;
}

cout << "Successfully connected and initialized the database." << endl;
return 0;
}
For an introduction to using the C# library:
http://blog.voltdb.com/introducing-voltdbnet-c-library-your-voltdb-applications/
20 changes: 20 additions & 0 deletions VoltDB.ClientLibrary.VS2012.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltDB.Data.Client", "VoltDB.Data.Client\VoltDB.Data.Client.csproj", "{F860E283-5A34-491B-A76B-B404D3CC3D47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F860E283-5A34-491B-A76B-B404D3CC3D47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F860E283-5A34-491B-A76B-B404D3CC3D47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F860E283-5A34-491B-A76B-B404D3CC3D47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F860E283-5A34-491B-A76B-B404D3CC3D47}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
16 changes: 4 additions & 12 deletions VoltDB.Data.Client/Connections/VoltConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,28 +493,20 @@ public static VoltConnection Create(ConnectionSettings settings)
/// <summary>
/// Internal flag tracking whether the object was disposed.
/// </summary>
private bool IsDisposed = false;
/// <summary>
/// Ensures connected resources are disposed.
/// </summary>
~VoltConnection()
{
this.Dispose();
}
private bool IsDisposed = false;
/// <summary>
/// Ensures connected resources are disposed.
/// </summary>
public void Dispose()
{
if (this.IsDisposed)
return;
if (this.IsDisposed)
return;
try
{
this.Close(true);
}
catch { }
this.IsDisposed = true;
GC.SuppressFinalize(this);
this.IsDisposed = true;
}
#endregion
}
Expand Down
4 changes: 0 additions & 4 deletions VoltDB.Data.Client/Protocol/VoltProtocolStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ private static Stream CreateSocketStream(IPEndPoint endPoint, int timeout)
throw new VoltConnectionException(Resources.ConnectionFailure, x, endPoint);
}

// Wrap a managed network stream on the socket, and make sure GC doesn't think the newly created socket
// should be discarded.
ManagedNetworkStream stream = new ManagedNetworkStream(socket, true);
GC.SuppressFinalize(socket);
GC.SuppressFinalize(stream);
return stream;
}
}
Expand Down
32 changes: 32 additions & 0 deletions VoltDB.Examples.VS2012.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltDB.Examples.Voter", "VoltDB.Examples\Voter\VoltDB.Examples.Voter.csproj", "{5A072211-56D9-4FFA-B776-B524744E8454}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltDB.Examples.HelloWorld", "VoltDB.Examples\HelloWorld\VoltDB.Examples.HelloWorld.csproj", "{655D5E0E-9A2E-4807-8A88-1A16DC082C69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltDB.Examples.KeyValue", "VoltDB.Examples\KeyValue\VoltDB.Examples.KeyValue.csproj", "{464AA9E7-02F2-4F05-826A-CE2630FBBCB1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A072211-56D9-4FFA-B776-B524744E8454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A072211-56D9-4FFA-B776-B524744E8454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A072211-56D9-4FFA-B776-B524744E8454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A072211-56D9-4FFA-B776-B524744E8454}.Release|Any CPU.Build.0 = Release|Any CPU
{655D5E0E-9A2E-4807-8A88-1A16DC082C69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{655D5E0E-9A2E-4807-8A88-1A16DC082C69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{655D5E0E-9A2E-4807-8A88-1A16DC082C69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{655D5E0E-9A2E-4807-8A88-1A16DC082C69}.Release|Any CPU.Build.0 = Release|Any CPU
{464AA9E7-02F2-4F05-826A-CE2630FBBCB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{464AA9E7-02F2-4F05-826A-CE2630FBBCB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{464AA9E7-02F2-4F05-826A-CE2630FBBCB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{464AA9E7-02F2-4F05-826A-CE2630FBBCB1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

0 comments on commit 43b688f

Please sign in to comment.