From 07989b12953546939e15b5823d7b9986aea4de82 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 13 Apr 2018 11:41:48 +0200 Subject: [PATCH] Blob Storage Module Fully Implemented --- .vs/AACloud/v15/.suo | Bin 85504 -> 73728 bytes Blob Storage.js | 99 +++++-------------------------------------- this.config.json | 6 +-- 3 files changed, 13 insertions(+), 92 deletions(-) diff --git a/.vs/AACloud/v15/.suo b/.vs/AACloud/v15/.suo index 50359c045223b63930c2cd3517d246cc23d9348d..fcee3c0978c2b262c96c5f8fb4f36067d6078b3e 100644 GIT binary patch delta 4488 zcmchadr;KZ7037d*o6gFSRMlM&=pWoK^`FyeBe(&l9(u|;24(1#soL2{}ZOy}n*X3iRVDL}$7nrs{Hx*0(qEGk9 zp^!EZ?JH;aq_nXhKh0O33^~A;?*};yEccb~GZ=;&o)`(neMeH4kdNA3X$`F%M-i zV?2<#iy7tfFrO4N#sa???Z}S?Fr(pN5Cz78Kr6POELN0$#EOYv1Sl~WS`C@VB!g`5 z2$&DVy0V!vf#Hy1UHNz-q*zxhDBG9|#Ok$>W+2v;c4A$Tr9PPhDUL5XvF<}41&oqW zM47}{p)>E7;TAx>5G(;w<4*;?@-m-%2C@#s?XHZc(A||uQR{p)tv=~ETKNv`Zm4ov zjmHOSOc0t3s_4q**auoz*a~Ha7L7H$#Z!oWNX8?Iii`K<7*ME z^ei_;P7U?!i`d_HhJ?@-{aWPqpb`K5ym@EN3|Fk;oO{A7!6Q!Q?~Hrqp5hM|<#Nx0 z%uZW^qT5n$k)HhMUx<~&5BNg`HHm1Uj%Pl!DnF0LuAF54|`DK0EAC-IXHBp$`xC8osZ3c(n_ ze~rsDdSW;s{(Dx`Vlz7ElOXXAsN2;p(rt;C$TdoFE-DEnX)!pU1=|-@7-K|n`fr&g z>8yx*7d>K@ISjk2-Qo&!5)`;%?sRXFSzMMKMsgJ?JZ)yQ9-SXy)NR`ilTpIYKNFK2 zb{4(2a2P5#W{^>iG=C-AH&q$sT=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= function newFileStorage(BOT) { initialize: initialize, createFolder: createFolder, createTextFile: createTextFile, - getTextFile: getTextFile, - listFilesAndFolders: listFilesAndFolders + getTextFile: getTextFile }; - let fileService; + let blobService; return thisObject; @@ -60,7 +59,7 @@ exports.newFileStorage = function newFileStorage(BOT) { } try { - fileService = storage.createBlobService(pConnObj.connectionString); + blobService = storage.createBlobService(pConnObj.connectionString); callBackFunction(global.DEFAULT_OK_RESPONSE); } catch (err) { @@ -100,7 +99,7 @@ exports.newFileStorage = function newFileStorage(BOT) { if (FULL_LOG === true) { logger.write("[INFO] createFolder -> Entering function."); } - if (fileService === undefined) { + if (blobService === undefined) { logger.write("[ERROR] createFolder -> initialize function not executed or failed. Can not process this request. Sorry."); callBackFunction(global.DEFAULT_FAIL_RESPONSE); @@ -123,7 +122,7 @@ exports.newFileStorage = function newFileStorage(BOT) { function createTextFile(pFolderPath, pFileName, pFileContent, callBackFunction) { - if (fileService === undefined) { + if (blobService === undefined) { logger.write("[ERROR] createTextFile -> initialize function not executed or failed. Can not process this request. Sorry."); callBackFunction(global.DEFAULT_FAIL_RESPONSE); @@ -139,7 +138,7 @@ exports.newFileStorage = function newFileStorage(BOT) { logger.write("[INFO] createTextFile -> pFileName = " + pFileName); } - fileService.createBlockBlobFromText(shareName, pFolderPath + "/" + pFileName, pFileContent, onFileCreated); + blobService.createBlockBlobFromText(shareName, pFolderPath + "/" + pFileName, pFileContent, onFileCreated); function onFileCreated(err, result, response) { @@ -170,7 +169,7 @@ exports.newFileStorage = function newFileStorage(BOT) { logger.write("[INFO] createTextFile -> onFileCreated -> secondTry -> Retrying to create the file."); - fileService.createFileFromText(shareName, pFolderPath, pFileName, pFileContent, onSecondTry); + blobService.createBlockBlobFromText(shareName, pFolderPath + "/" + pFileName, pFileContent, onSecondTry); function onSecondTry(err, result, response) { @@ -202,7 +201,7 @@ exports.newFileStorage = function newFileStorage(BOT) { function getTextFile(pFolderPath, pFileName, callBackFunction) { - if (fileService === undefined) { + if (blobService === undefined) { logger.write("[ERROR] getTextFile -> initialize function not executed or failed. Can not process this request. Sorry."); callBackFunction(global.DEFAULT_FAIL_RESPONSE); @@ -218,7 +217,7 @@ exports.newFileStorage = function newFileStorage(BOT) { logger.write("[INFO] getTextFile -> pFileName = " + pFileName); } - fileService.getBlobToText(shareName, pFolderPath + "/" + pFileName, onFileReceived); + blobService.getBlobToText(shareName, pFolderPath + "/" + pFileName, onFileReceived); function onFileReceived(err, text, response) { @@ -248,7 +247,7 @@ exports.newFileStorage = function newFileStorage(BOT) { logger.write("[INFO] getTextFile -> onFileReceived -> secondTry -> Retrying to get the file."); - fileService.getFileToText(shareName, pFolderPath, pFileName, undefined, onSecondTry); + blobService.getBlobToText(shareName, pFolderPath + "/" + pFileName, onSecondTry); function onSecondTry(err, text, response) { @@ -310,82 +309,4 @@ exports.newFileStorage = function newFileStorage(BOT) { } } - function listFilesAndFolders(pFolderPath, callBackFunction) { - - if (fileService === undefined) { - - logger.write("[ERROR] listFilesAndFolders -> initialize function not executed or failed. Can not process this request. Sorry."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - } - - try { - - let items = { - files: [], - folders: [] - }; - - /* - * AZURE HELP: - * - * @param { object } [options] The request options. - * @param { int } [options.maxResults] Specifies the maximum number of folders to return per call to Azure ServiceClient. - * This does NOT affect list size returned by this function. (maximum: 5000) - * @param { LocationMode } [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. - * Please see StorageUtilities.LocationMode for the possible values. - * @param { int } [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. - * @param { int } [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. - * The maximum execution time interval begins at the time that the client begins building the request.The maximum - * execution time is checked intermittently while performing requests, and before executing retries. - * @param { string } [options.clientRequestId] A string that represents the client request ID with a 1KB character limit. - * @param { bool } [options.useNagleAlgorithm] Determines whether the Nagle al - */ - - let options = { - maxResults: 500 - }; - - if (FULL_LOG === true) { - logger.write("[INFO] listFilesAndFolders -> About to get the list of files and folders."); - logger.write("[INFO] listFilesAndFolders -> shareName = " + shareName); - logger.write("[INFO] listFilesAndFolders -> pFolderPath = " + pFolderPath); - } - - fileService.listFilesAndDirectoriesSegmented(shareName, pFolderPath, null, options, onFilesAndFoldersReceived); - - function onFilesAndFoldersReceived(err, result) { - - try { - if (FULL_LOG === true) { - logger.write("[INFO] listFilesAndFolders -> onFileReceived -> Response from Azure received."); - logger.write("[INFO] listFilesAndFolders -> onFileReceived -> shareName = " + shareName); - logger.write("[INFO] listFilesAndFolders -> onFileReceived -> pFolderPath = " + pFolderPath); - } - - if (err) { - - logger.write("[ERROR] 'listFilesAndFolders' -> onFilesAndFoldersReceived -> err = " + err); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - return; - - } else { - - items.files.push.apply(items.files, result.entries.files); - items.folders.push.apply(items.folders, result.entries.directories); - - callBackFunction(global.DEFAULT_OK_RESPONSE, items); - } - } - catch (err) { - const logText = "[ERROR] 'listFilesAndFolders - onFilesAndFoldersReceived' - ERROR : " + err.message; - logger.write(logText); - } - } - } - catch (err) { - logger.write("[ERROR] 'listFilesAndFolders' -> err = " + err.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - } - } }; \ No newline at end of file diff --git a/this.config.json b/this.config.json index af7433105..d98f6a7ca 100644 --- a/this.config.json +++ b/this.config.json @@ -17,7 +17,7 @@ "process": "Multi-Period-Market" }, { - "enabled": "true", + "enabled": "false", "botPath": "../Bots/AAMasters/AAOlivia-Indicator-Bot", "process": "Multi-Period-Daily" }, @@ -32,13 +32,13 @@ "process": "Poloniex-Hole-Fixing" }, { - "enabled": "false", + "enabled": "true", "botPath": "../Bots/AAMasters/AACharly-Extraction-Bot", "process": "Poloniex-Live-Trades" } ], "stopGracefully": "false", "exchangeSimulationMode": "false", - "storageConnStringFolder": "Production", + "storageConnStringFolder": "Testnet", "maxLogLoops": 5 } \ No newline at end of file