#!/usr/bin/python import string import time import urllib import os.path # If you want to see the commands as they execute, set this to 1. verbose = 0 files = { "gemfire" : { "name" : "GemFire JAR", "file" : "gemfire-6.5.1.jar", "url" : "http://dist.gemstone.com/maven/release/com/gemstone/gemfire/gemfire/6.5.1/", "sum" : "f9b633da145a2afb27d2015ab76010818c0c2ee2" }, "antlr" : { "name" : "ANTLR JAR", "file" : "antlr-3.1.3.jar", "url" : "http://www.antlr.org/download/", "sum" : "acd5253cf1eba7bdb133f14cd77b0ba2fd219f98" }, "examples" : { "name" : "GemFire Examples", "file" : "GemFire_v6.5_SampleCode.zip", "url" : "http://community.gemstone.com/download/attachments/6032137/", "sum" : "6a1d6f5e4a9a4e1236caecac2935b5cb841bcb10" } } demos = { 'BenchmarkAckConsumer' : {}, 'BenchmarkAckProducer' : {}, 'BenchmarkClient' : { "cacheServerArgs" : "start cache-xml-file=xml/BenchmarkServer.xml" }, 'ClientConsumer' : { "cacheServerArgs" : "start cache-xml-file=xml/Server.xml" }, 'ClientWorker' : {}, 'CqClient' : { "cacheServerArgs" : "start cache-xml-file=xml/CqServer.xml" }, 'DataEviction' : {}, 'DataExpiration' : {}, 'DataOverflow' : {}, 'DataPersistence' : {}, 'DeltaPropagationClientFeeder' : { "cacheServerArgs" : "start cache-xml-file=xml/DeltaServer.xml" }, 'DeltaPropagationClientReceiver' : {}, 'DeltaPropagationServer' : {}, 'DistributedLocking' : {}, 'DurableClient' : {}, 'DurableServer' : {}, 'FunctionExecutionPeer1' : {}, 'FunctionExecutionPeer2' : {}, 'I18nClient' : {}, 'MultiuserSecurityClient' : {}, 'MultiuserSecurityServer' : {}, 'MyArrayListResultCollector' : {}, 'PartitionedRegionVM1' : {}, 'PartitionedRegionVM2' : {}, 'PushConsumer' : {}, 'PushProducer' : {}, 'Querying' : {}, 'SecurityClient' : {}, 'SecurityServer' : {}, 'Transactions' : {}, } def download(url, file): urllib.urlretrieve(url, file) def downloadFile(fileInfo): # Check to see if the file exists. if os.path.isfile(fileInfo["file"]): return # Otherwise download it. url = fileInfo["url"] + fileInfo["file"] print "Downloading " + fileInfo["name"] download(url, fileInfo["file"]) # Validate the checksum. Error if it doesn't match. #if (checkSHA1): # if (checksum(fileInfo["file"]) != fileInfo["sum"]): # unlink(fileInfo["file"]) # raise Exception("Bad checksum") def runDemo(demoName, args=""): baseCommand = "java -classpath classes:../gemfire-6.5.1.jar:../antlr-3.1.3.jar" fullCommand = baseCommand + " quickstart." + demoName + " " + args os.chdir("quickstart") # Some demos require a cache server. Start one up. cacheServerNeeded = 0 if "cacheServerArgs" in demos[demoName]: cacheServerNeeded = 1 print "Starting a cache server for this demo." cacheServerCommand = baseCommand + \ " com.gemstone.gemfire.internal.cache.CacheServerLauncher " + \ demos[demoName]["cacheServerArgs"] if verbose: print "Starting cache server using: ", cacheServerCommand os.system(cacheServerCommand) # Start the demo. if verbose: print "Starting demo using: ", fullCommand os.system(fullCommand) # Stop the cache server if we started one. if cacheServerNeeded: print "Stopping cache server." cacheServerCommand = baseCommand + \ " com.gemstone.gemfire.internal.cache.CacheServerLauncher stop" os.system(cacheServerCommand) if verbose: print "Stopping cache server using: ", cacheServerCommand os.chdir("..") demoName = raw_input("Press enter to return to the menu.") def doMenu(): while 1: print "Ready to run a demo." # Present choices. after = "" demoNames = demos.keys() demoNames.sort() for demo in demoNames: formattedDemo = "%-33s" % demo print formattedDemo, after, if after == "": after = "\n" else: after = "" print input = raw_input("Enter your choice: ") tokens = input.split(" ") demoName = tokens[0] arguments = string.join(tokens[1:], " ") try: demos[demoName] runDemo(demoName, arguments) except KeyError, ValueError: print "Unknown demo, try again." time.sleep(1) def main(): # Ensure we have all the files we need. for file in files.keys(): downloadFile(files[file]) # Extract the samples if they don't already exist. if not os.path.isdir("quickstart"): os.system("unzip -n -q GemFire_v6.5_SampleCode.zip") # Disable verbose output. fd = open("quickstart/classes/gemfire.properties", "w") fd.write("log-level=warning") fd.close() doMenu() main()