如何从zookeeper下载Solr集合配置(How to download Solr collection config from zookeeper)
我在solrcloud中有一个集合,它是使用zookeeper托管配置创建的,我想要用于创建集合的所有集合配置文件。 以下是我找到的选项:
从Solrcloud UI手动复制所有文件。
solrUI->cloud->tree->/collections/<collection-name>
从zookeeper下载文件
/opt/solr/server/scripts/cloud-scripts/zkcli.sh -cmd downconfig -zkhost <zk hosts>/usecasedir -confname <configuration name> -confdir <dir to download>
第二个选项wold节省了我很多时间,但问题在于我的zookeeper有很多配置列表,我不确定用于创建集合的配置目录。
有没有办法找出用于创建集合的集合配置?
I have a collection in solrcloud which had been created using zookeeper managed configuration and I want all collection configuration files which were used to create the collection. Here are the options I found:
Copy manually all files from Solrcloud UI.
solrUI->cloud->tree->/collections/<collection-name>
Download files from zookeeper
/opt/solr/server/scripts/cloud-scripts/zkcli.sh -cmd downconfig -zkhost <zk hosts>/usecasedir -confname <configuration name> -confdir <dir to download>
2nd option would save my lot of time but the problem here my zookeeper has huge list of configurations and I am not sure which configuration directory was used to create collection.
Is there any way to figure out which collection configuration was used to create collection?
原文:https://stackoverflow.com/questions/44166094
最满意答案
移动视口以使玩家保持在中心位置非常简单:
你可以简单地使用
ctx.setTransform(1, 0, 0, 1, centerX - player.x, centerY - player.Y)
;现在,使用当前的鼠标逻辑,您实际上需要一个
viewPort
对象,只有两个属性x
和y
这样您仍然可以获得光标和播放器之间的正确距离。您还显然需要删除在
setPlayerTarget_and_checkPlayerPosition
函数中setPlayerTarget_and_checkPlayerPosition
的边界检查。function randomNumberFromRange( min, max ) { return Math.floor(Math.random() * (max - min + 1)) + min; } function testCollisionRectRect( rectangle1, rectangle2 ) { return rectangle1.x - rectangle1.width/2 <= rectangle2.x - rectangle2.width/2 + rectangle2.width && rectangle2.x - rectangle2.width/2 <= rectangle1.x - rectangle1.width/2 + rectangle1.width && rectangle1.y - rectangle1.height/2 <= rectangle2.y - rectangle2.height/2 + rectangle2.height && rectangle2.y - rectangle2.height/2 <= rectangle1.y - rectangle1.height/2 + rectangle1.height; } Array.prototype.remove = function() { var what, a = arguments, L = a.length, ax; while (L && this.length) { what = a[--L]; while ((ax = this.indexOf(what)) !== -1) { this.splice(ax, 1); } } return this; }; // Function to pop specific element drom array by value function drawLine( startX, startY, endX, endY, color, width ) { ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = width; ctx.beginPath(); ctx.moveTo(startX,startY); ctx.lineTo(endX,endY); ctx.stroke(); ctx.restore(); } function drawBorder( x, y, width, height, lineWidth, strokeColor ) { ctx.save(); ctx.lineWidth = lineWidth; ctx.strokeStyle = strokeColor; ctx.strokeRect( x, y, width, height); ctx.restore(); } function drawRect( x, y, width, height, fillColor ) { ctx.save(); ctx.fillStyle = fillColor; ctx.fillRect( x, y, width, height ); ctx.restore(); } // ==================== // Global variables // ==================== var ctx = $("#canvas")[0].getContext('2d'), canvas = document.getElementById('canvas'), cHeight = canvas.height = 500, cWidth = canvas.width = 500, canvasOffset = $('#canvas').offset(), offsetX = canvasOffset.left, offsetY = canvasOffset.top, frameCounter = 0, enemyList = [], spawningEnemies_FLAG = true, isLeftMouseButtonHeld_FLAG = false, cursors = ['default', 'pointer'], enemiesOnMap = 100, fps = 120, mouseX, mouseY; // canvas settings ctx.font = '22px Arial'; var viewPort = { x: cWidth/2, y: cHeight/2, update() { this.x = cWidth / 2 - player.x; this.y = cHeight / 2 - player.y; } }; var sharedBehaviour = { x: cWidth / 2, y: cHeight / 2, id: undefined, type: 'entity', width: 15, height: 15, fillColor: '#E15258', targetX: null, targetY: null, bulletSpeed: 1, speed: 1, update( type ) { // if there is target if( this.targetX !== null ) { // Find out distance to target var distanceX = this.targetX - this.x; // distance on X axis var distanceY = this.targetY - this.y; // distance on Y axis var distanceToTarget = Math.sqrt( distanceX*distanceX + distanceY*distanceY ); // distance // If distance is smaller or equal speed, then just set position if( distanceToTarget <= this.speed ) { this.x = this.targetX; this.y = this.targetY; // Then reset this.targetX = this.targetY = null; } else { // If distance is bigger than speed, so we want to move with speed distanceX = distanceX / distanceToTarget; distanceY = distanceY / distanceToTarget; distanceX = distanceX * this.speed; distanceY = distanceY * this.speed; this.x += distanceX; this.y += distanceY; } } }, draw( type ) { drawRect( this.x - this.width/2, this.y - this.height/2, this.width, this.height, this.fillColor ); }, isColliding( entity ) { return testCollisionRectRect( this, entity ); } }; var player = Object.assign({}, sharedBehaviour, { x: cWidth/2 - 12.5, y: cHeight/2 - 12.5, id: 980722, type: 'player', width: 25, height: 25, fillColor: '#82d877', speed: 2.5, isWithinRange( entity, val ) { // Check if enemy is on player var distanceX = this.x - entity.x; var distanceY = this.y - entity.y; return Math.sqrt( distanceX*distanceX + distanceY*distanceY ) < val; } }); function createEnemy( x, y, type, width, height, fillColor, speed, name ) { var newEnemy = Object.assign({}, sharedBehaviour, { x, y, type, width, height, name, fillColor, speed, setTarget( entity ) { this.targetX = entity.x + randomNumberFromRange(-50, 50); // Set X with some random number this.targetY = entity.y + randomNumberFromRange(-50, 50); // Set Y with some random number }, isOnPlayer( val ) { // Check if enemy is on player var distanceX = player.x - this.x; var distanceY = player.y - this.y; return Math.sqrt( distanceX*distanceX + distanceY*distanceY ) < val; }, isMouseOver( ) { return (this.mouseX + this.width/2 >= this.x && this.mouseX + this.width/2 <= this.x + this.width && this.mouseY + this.height/2 >= this.y && this.mouseY + this.height/2 <= this.y + this.height); } }); enemyList.push( newEnemy ); } function newGame( ) { player.x = cWidth/2 - 12.5; player.y = cHeight/2 - 12.5; frameCounter = 0; enemyList = []; spawningEnemies_FLAG = true; isLeftMouseButtonHeld_FLAG = false; // Spawning enemies for( i=0; i < randomNumberFromRange(15, 25); i++ ) { createEnemy( randomNumberFromRange(0, cWidth), randomNumberFromRange(0, cHeight), 'passive', randomNumberFromRange(12, 18), randomNumberFromRange(12, 18), 'red', 1, 's' ); createEnemy( randomNumberFromRange(0, cWidth), randomNumberFromRange(0, cHeight), 'agressive', randomNumberFromRange(10, 16), randomNumberFromRange(10, 16), 'lightblue', 1.5, 'l' ); } update(); } function update( ) { frameCounter++; ctx.setTransform(1,0,0,1,0,0); // reset before clearing ctx.clearRect(0,0,cWidth,cHeight); // ========== Update ========== // Player player.update('player'); // Enemies enemyList.forEach( enemy => { enemy.update(); }); // viewPort viewPort.update() // ========== Draw ========== // viewPort ctx.setTransform(1,0,0,1, viewPort.x, viewPort.y); // Enemies enemyList.forEach( enemy => { enemy.draw(); }); // Player player.draw('player'); // ========== Conditions ========== // Enemies // Behaviour enemyList.forEach( enemy => { if ( Math.random() < ( 1 / 15 ) ) { if ( enemy.isOnPlayer( player.circleRadius ) ) { if ( ! (enemy.isOnPlayer( 50 )) ) { enemy.setTarget( player ); } } } if ( Math.random() < ( 1 / 800 )) { if ( ! (enemy.isOnPlayer( player.circleRadius )) ) enemy.setTarget( enemy ); } if ( enemy.isOnPlayer(player.circleRadius/2 - 25 ) ) { enemy.targetX = enemy.targetY = null; } ( enemyList.length === enemiesOnMap ) ? spawningEnemies_FLAG = false : spawningEnemies_FLAG = true; }); // this is bad vvv // setTimeout(function() { requestAnimationFrame(update); //}, 1000 / fps); } function setPlayerTarget_and_checkPlayerPosition( mouse ) { player.targetX = mouseX; player.targetY = mouseY; // a few lines are gone here... } canvas.addEventListener('mousedown', function( mouse ) { isLeftMouseButtonHeld_FLAG = true; setPlayerTarget_and_checkPlayerPosition(mouse); }); canvas.addEventListener('mouseup', function( mouse ) { isLeftMouseButtonHeld_FLAG = false; }); canvas.addEventListener('mousemove', function( mouse ) { if( isLeftMouseButtonHeld_FLAG ) { setPlayerTarget_and_checkPlayerPosition(mouse); } }); canvas.addEventListener('mousemove', function( mouse ) { var rect = canvas.getBoundingClientRect(); // offset may change in snippets mouseX = parseInt(mouse.clientX - rect.left - viewPort.x); mouseY = parseInt(mouse.clientY - rect.top - viewPort.y); }); newGame();
canvas { border: 1px solid black; background-color: white; }
<canvas id="canvas"></canvas> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Moving the viewport in order to keep the player's at center is quite easy :
You can simply use
ctx.setTransform(1, 0, 0, 1, centerX - player.x, centerY - player.Y)
;Now, with your current mouse logic, you actually need an
viewPort
object, with only two propertiesx
andy
so that you can still get the correct distance between the cursor and your player.You also obviously need to remove the bounding checks you did in
setPlayerTarget_and_checkPlayerPosition
function.function randomNumberFromRange( min, max ) { return Math.floor(Math.random() * (max - min + 1)) + min; } function testCollisionRectRect( rectangle1, rectangle2 ) { return rectangle1.x - rectangle1.width/2 <= rectangle2.x - rectangle2.width/2 + rectangle2.width && rectangle2.x - rectangle2.width/2 <= rectangle1.x - rectangle1.width/2 + rectangle1.width && rectangle1.y - rectangle1.height/2 <= rectangle2.y - rectangle2.height/2 + rectangle2.height && rectangle2.y - rectangle2.height/2 <= rectangle1.y - rectangle1.height/2 + rectangle1.height; } Array.prototype.remove = function() { var what, a = arguments, L = a.length, ax; while (L && this.length) { what = a[--L]; while ((ax = this.indexOf(what)) !== -1) { this.splice(ax, 1); } } return this; }; // Function to pop specific element drom array by value function drawLine( startX, startY, endX, endY, color, width ) { ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = width; ctx.beginPath(); ctx.moveTo(startX,startY); ctx.lineTo(endX,endY); ctx.stroke(); ctx.restore(); } function drawBorder( x, y, width, height, lineWidth, strokeColor ) { ctx.save(); ctx.lineWidth = lineWidth; ctx.strokeStyle = strokeColor; ctx.strokeRect( x, y, width, height); ctx.restore(); } function drawRect( x, y, width, height, fillColor ) { ctx.save(); ctx.fillStyle = fillColor; ctx.fillRect( x, y, width, height ); ctx.restore(); } // ==================== // Global variables // ==================== var ctx = $("#canvas")[0].getContext('2d'), canvas = document.getElementById('canvas'), cHeight = canvas.height = 500, cWidth = canvas.width = 500, canvasOffset = $('#canvas').offset(), offsetX = canvasOffset.left, offsetY = canvasOffset.top, frameCounter = 0, enemyList = [], spawningEnemies_FLAG = true, isLeftMouseButtonHeld_FLAG = false, cursors = ['default', 'pointer'], enemiesOnMap = 100, fps = 120, mouseX, mouseY; // canvas settings ctx.font = '22px Arial'; var viewPort = { x: cWidth/2, y: cHeight/2, update() { this.x = cWidth / 2 - player.x; this.y = cHeight / 2 - player.y; } }; var sharedBehaviour = { x: cWidth / 2, y: cHeight / 2, id: undefined, type: 'entity', width: 15, height: 15, fillColor: '#E15258', targetX: null, targetY: null, bulletSpeed: 1, speed: 1, update( type ) { // if there is target if( this.targetX !== null ) { // Find out distance to target var distanceX = this.targetX - this.x; // distance on X axis var distanceY = this.targetY - this.y; // distance on Y axis var distanceToTarget = Math.sqrt( distanceX*distanceX + distanceY*distanceY ); // distance // If distance is smaller or equal speed, then just set position if( distanceToTarget <= this.speed ) { this.x = this.targetX; this.y = this.targetY; // Then reset this.targetX = this.targetY = null; } else { // If distance is bigger than speed, so we want to move with speed distanceX = distanceX / distanceToTarget; distanceY = distanceY / distanceToTarget; distanceX = distanceX * this.speed; distanceY = distanceY * this.speed; this.x += distanceX; this.y += distanceY; } } }, draw( type ) { drawRect( this.x - this.width/2, this.y - this.height/2, this.width, this.height, this.fillColor ); }, isColliding( entity ) { return testCollisionRectRect( this, entity ); } }; var player = Object.assign({}, sharedBehaviour, { x: cWidth/2 - 12.5, y: cHeight/2 - 12.5, id: 980722, type: 'player', width: 25, height: 25, fillColor: '#82d877', speed: 2.5, isWithinRange( entity, val ) { // Check if enemy is on player var distanceX = this.x - entity.x; var distanceY = this.y - entity.y; return Math.sqrt( distanceX*distanceX + distanceY*distanceY ) < val; } }); function createEnemy( x, y, type, width, height, fillColor, speed, name ) { var newEnemy = Object.assign({}, sharedBehaviour, { x, y, type, width, height, name, fillColor, speed, setTarget( entity ) { this.targetX = entity.x + randomNumberFromRange(-50, 50); // Set X with some random number this.targetY = entity.y + randomNumberFromRange(-50, 50); // Set Y with some random number }, isOnPlayer( val ) { // Check if enemy is on player var distanceX = player.x - this.x; var distanceY = player.y - this.y; return Math.sqrt( distanceX*distanceX + distanceY*distanceY ) < val; }, isMouseOver( ) { return (this.mouseX + this.width/2 >= this.x && this.mouseX + this.width/2 <= this.x + this.width && this.mouseY + this.height/2 >= this.y && this.mouseY + this.height/2 <= this.y + this.height); } }); enemyList.push( newEnemy ); } function newGame( ) { player.x = cWidth/2 - 12.5; player.y = cHeight/2 - 12.5; frameCounter = 0; enemyList = []; spawningEnemies_FLAG = true; isLeftMouseButtonHeld_FLAG = false; // Spawning enemies for( i=0; i < randomNumberFromRange(15, 25); i++ ) { createEnemy( randomNumberFromRange(0, cWidth), randomNumberFromRange(0, cHeight), 'passive', randomNumberFromRange(12, 18), randomNumberFromRange(12, 18), 'red', 1, 's' ); createEnemy( randomNumberFromRange(0, cWidth), randomNumberFromRange(0, cHeight), 'agressive', randomNumberFromRange(10, 16), randomNumberFromRange(10, 16), 'lightblue', 1.5, 'l' ); } update(); } function update( ) { frameCounter++; ctx.setTransform(1,0,0,1,0,0); // reset before clearing ctx.clearRect(0,0,cWidth,cHeight); // ========== Update ========== // Player player.update('player'); // Enemies enemyList.forEach( enemy => { enemy.update(); }); // viewPort viewPort.update() // ========== Draw ========== // viewPort ctx.setTransform(1,0,0,1, viewPort.x, viewPort.y); // Enemies enemyList.forEach( enemy => { enemy.draw(); }); // Player player.draw('player'); // ========== Conditions ========== // Enemies // Behaviour enemyList.forEach( enemy => { if ( Math.random() < ( 1 / 15 ) ) { if ( enemy.isOnPlayer( player.circleRadius ) ) { if ( ! (enemy.isOnPlayer( 50 )) ) { enemy.setTarget( player ); } } } if ( Math.random() < ( 1 / 800 )) { if ( ! (enemy.isOnPlayer( player.circleRadius )) ) enemy.setTarget( enemy ); } if ( enemy.isOnPlayer(player.circleRadius/2 - 25 ) ) { enemy.targetX = enemy.targetY = null; } ( enemyList.length === enemiesOnMap ) ? spawningEnemies_FLAG = false : spawningEnemies_FLAG = true; }); // this is bad vvv // setTimeout(function() { requestAnimationFrame(update); //}, 1000 / fps); } function setPlayerTarget_and_checkPlayerPosition( mouse ) { player.targetX = mouseX; player.targetY = mouseY; // a few lines are gone here... } canvas.addEventListener('mousedown', function( mouse ) { isLeftMouseButtonHeld_FLAG = true; setPlayerTarget_and_checkPlayerPosition(mouse); }); canvas.addEventListener('mouseup', function( mouse ) { isLeftMouseButtonHeld_FLAG = false; }); canvas.addEventListener('mousemove', function( mouse ) { if( isLeftMouseButtonHeld_FLAG ) { setPlayerTarget_and_checkPlayerPosition(mouse); } }); canvas.addEventListener('mousemove', function( mouse ) { var rect = canvas.getBoundingClientRect(); // offset may change in snippets mouseX = parseInt(mouse.clientX - rect.left - viewPort.x); mouseY = parseInt(mouse.clientY - rect.top - viewPort.y); }); newGame();
canvas { border: 1px solid black; background-color: white; }
<canvas id="canvas"></canvas> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
相关问答
更多-
LIVE DEMO在jsfiddle.net 本演示说明真实游戏场景中的视口使用情况。 使用箭头键将玩家移到房间。 大房间使用矩形在飞行中生成,并将结果保存到图像中。 注意玩家总是在中间,除非靠近边界(如你所愿)。 现在我将尝试解释代码的主要部分,至少是仅仅看着它更难以理解的部分。 使用drawImage根据视口位置绘制较大的图像 drawImage方法的变体有八个新参数。 我们可以使用这种方法对源图像的一部分进行切片并将它们绘制到画布上。 drawImage(image,sx,sy,sWidth,sHei ...
-
首先,使用正交相机。 camera=new OrthographicCamera(800,480); camera.position.set(800/2f,480/2f,0); viewport=new FitViewport(800,480,camera); 现在0,0位于屏幕的左下角。 在进行batch.begin之前,不要忘记设置投影矩阵 batch.setProjectionMatrix(camera.combined); batch.begin(); //// //// batch.end(); ...
-
ScreenViewport在这里不是很好,因为你的游戏在smaprtphone的屏幕上会很好看,因为它在平板电脑的中心会是一个小多边形。 您应该考虑使用FitViewport ,它会在屏幕上添加条形图,但可以为每个设备保持相同的竞技场尺寸。 要定义虚拟屏幕应具有的分辨率,只需在视口的构造函数中传递它 private FitViewport viewport; public GameScreen(AudioSnake audioSnake) { gameCore = aud ...
-
尝试将视口存储在变量中。 var view = {x: 0, y: 0}; 然后,在绘制循环/渲染功能的开头,保存画布状态并转换为视口。 ctx.save(); ctx.translate(view.x, view.y); 如果你想view.x和view.y来表示视图的中心,而是像这样翻译: ctx.translate(view.x - canvas.width/2, view.y - canvas.height/2); 在绘制循环/渲染功能结束时,恢复状态,以便翻译不会叠加。 ctx.restore ...
-
游戏视口焦点与y轴上的碰撞检测相对于重力(game viewport focus vs collision detection on y axis against gravity)[2022-02-01]
http://jsbin.com/Stop-Elements-Move-After-Collision/2/edit 你得到每个requestAnimationFrame元素选择器( 而不是缓存它 ), 元素高度, 位置和很多其他的东西,这是糟糕的浏览器不必要的过度杀伤。 你的问题是你正在更新元素位置,而不是重新重置那个位置 - >因此,你所能看到的只是一个有趣的性感表演! 而是使用Object Literals {} 存储有关元素 ,位置,宽度......一切的所有内容。 甚至jQuery元素引用$('# ... -
帆布简单的游戏视口(Canvas simple game viewport)[2022-02-08]
移动视口以使玩家保持在中心位置非常简单: 你可以简单地使用ctx.setTransform(1, 0, 0, 1, centerX - player.x, centerY - player.Y) ; 现在,使用当前的鼠标逻辑,您实际上需要一个viewPort对象,只有两个属性x和y这样您仍然可以获得光标和播放器之间的正确距离。 您还显然需要删除在setPlayerTarget_and_checkPlayerPosition函数中setPlayerTarget_and_checkPlayerPosition的 ... -
更改OpenGL视图的任何方面都需要完全重绘场景。 由于典型的OpenGL渲染将包括叠加(HUD,注释等),因此将视口和投影矩阵与绘图分开设置是没有意义的。 因此,应在绘图程序中执行glViewport和投影矩阵设置。 窗口大小或其他查看方面的任何更改都必须触发完全重绘,并且在绘图例程中设置视口和投影可以处理,而无需进一步考虑。 Changing any aspect of an OpenGL view requires a complete redraw of the scene. Since a typ ...
-
Libgdx视口没有伸展(Libgdx viewport not stretching)[2022-03-24]
您必须将摄像机和视口设置为用于编程世界的值:例如。 如果你的世界是800 * 480: camera = new OrthographicCamera(800,480); fitViewport = new FitViewport(800, 480, camera); You have to set the camera and viewport to the value u used to program the world: eg. If your world is 800*480: camera = ... -
帆布游戏帧率下降(Canvas game framerate drop)[2024-03-06]
在使用ctx.rect , moveTo , lineTo , arc以及使用ctx.stroke()或ctx.fill()查看所需的任何函数之前,需要添加ctx.beginPath() 。 beginPath告诉您希望开始新形状的画布2D上下文。 如果你不这样做,你最终会在每次更新中添加越来越多的形状。 来自你的小提琴 function update() { ctx.clearRect(0, 0, width, height); ctx.fillStyle = pat; //========= ... -
您可能想要使用ExtendViewport 。 这扩展了世界1种方式来填充整个屏幕。 你的代码看起来像这样: private Viewport viewport; private Camera camera; public void create() { camera = new OrthographicCamera(); viewport = new ExtendViewport(VIEWPORT_WIDTH , VIEWPORT_HEIGHT, camera); } public ...