首页 文章 精选 留言 我的

精选列表

搜索[设置],共10000篇文章
优秀的个人博客,低调大师

Android笔记:测量控件宽高和动态设置控件宽高

1.测算控件宽高 初始化UI时,无法直接通过getWidth()或getHeight()获取到控件的宽度或高度。可采用定时测算去获取控件的宽度/高度,方法如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 //每隔10毫秒测算一次宽度,直到测算完毕 mMeasureAction = new Runnable() { @Override public void run() { if (mLayout_map.getWidth() != 0 ) { Log.i( "w" , mLayout_map.getWidth() + "" ); Log.i( "h" , mLayout_map.getHeight() + "" ); } else { mLayout_map.postDelayed(mMeasureAction, 10 ); } } }; mLayout_map.postDelayed(mMeasureAction, 10 ); 参考资料:http://blog.163.com/zhaolin53636848@126/blog/static/490866682012065373798/ 2.动态修改控件的宽高 比如,将imageview的宽度改为200,高度改为宽度的3/4。其中RelativeLayout是imageview的父布局,方法如下: 1 import android.widget.RelativeLayout.LayoutParams; 1 2 3 4 5 6 int imgWeight = 200 ; RelativeLayout.LayoutParams sp_params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); sp_params.width = imgWeight; sp_params.height = imgWeight * 3 / 4 ; imageView.setLayoutParams(sp_params); 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1358564,如需转载请自行联系原作者

优秀的个人博客,低调大师

Recovering unassigned shards on elasticsearch 2.x——副本shard可以设置replica为...

Recovering unassigned shards on elasticsearch 2.x 摘自:https://z0z0.me/recovering-unassigned-shards-on-elasticsearch/ I got accross the problem when decided to add a node to the elasticsearch cluster and that node was not able to replicate the indexes of the cluster. This issue is usually happens when there is not enough disk space available, or not available master or different elasticsearch version. While my servers had more than enough disk space and also the master was available with the help of theelasticsearch discussI found out that the new node was having a different version than old nodes. Basically while installing on Debian jessie I just runapt-get install elasticsearchwhich ended up installing the latest available version. To install a specific version of the elasticsearch you prety much need to add={version}. #apt-get install elasticsearch={version} Now that I have identified the reasons for unallocated shards and successfully downgraded the elasticsearch to the required version by running the command above after starting the node the cluster was still in red state with unassigned shards all over the place: #curl http://localhost:9200/_cluster/health?pretty { "cluster_name" : "z0z0", "status" : "red", "timed_out" : false, "number_of_nodes" : 3, "number_of_data_nodes" : 3, "active_primary_shards" : 6, "active_shards" : 12, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 8, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 60.0 } #curl http://localhost:9200/_cat/shards site-id 4 p UNASSIGNED site-id 4 r UNASSIGNED site-id 1 p UNASSIGNED site-id 1 r UNASSIGNED site-id 3 p STARTED 0 159b 10.0.0.6 node-2 site-id 3 r STARTED 0 159b 10.0.0.7 node-3 site-id 2 r STARTED 0 159b 10.0.0.6 node-2 site-id 2 p STARTED 0 159b 10.0.0.7 node-3 site-id 0 r STARTED 0 159b 10.0.0.6 node-2 site-id 0 p STARTED 0 159b 10.0.0.7 node-3 subscription 4 p UNASSIGNED subscription 4 r UNASSIGNED subscription 1 p UNASSIGNED subscription 1 r UNASSIGNED subscription 3 p STARTED 0 159b 10.0.0.6 node-2 subscription 3 r STARTED 0 159b 10.0.0.7 node-3 subscription 2 r STARTED 0 159b 10.0.0.6 node-2 subscription 2 p STARTED 0 159b 10.0.0.7 node-3 subscription 0 p STARTED 0 159b 10.0.0.6 node-2 subscription 0 r STARTED 0 159b 10.0.0.7 node-3 At this point I was pretty desperate and whatever I tried it either did not do anything or ended up in all kind of failures. So I set thenumber_of_replicasto0by running the following query: #curl -XPUT http://localhost:9200/_settings?pretty -d ' { "index" : { "number_of_replicas' : 0 } }' and started to stop the nodes one by one until I was having only one live node. At this point I decided to start trying to reroute the unassigned shards and if it won't work I would just start over my cluster. So I did run the following: #curl -XPOST -d ' { "commands" : [ { "allocate" : { "index" : "site-id", "shard" : 1, "node" : "node-3", "allow_primary" : true } } ] }' http://localhost:9200/_cluster/reroute?pretty I've seen that the rerouted shard became initialized then running so I did the same command on the rest of unassigned shards. Runningcurl http://localhost:9200/_cluster/health?prettyconfirmed that I am on the good track to fix the cluster. #curl http://localhost:9200/_cluster/health?pretty { "cluster_name" : "z0z0", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 10, "active_shards" : 20, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 } So the cluster was green again but was running out of one node. So it was time to bring up the other nodes one by one. When all the nodes were up I set thenumber_of_replicasto1by running the following: #curl -XPUT http://localhost:9200/_settings -d ' { "index" : { "number_of_replicas" : 1 } }' So my elasticsearch cluster is back on running 3 nodes and still in green state. After alot of googling and wasted time I decided to write this article so that if anyone would come accross this issue would have a working example of how to fix it. 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/7459391.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册