virtual

Keepalived高可用

拈花ヽ惹草 提交于 2019-12-29 22:37:28
Keepalived Keepalived 是一个基于 VRRP 协议(Virtual Router Redundancy Protocol)的路由软件,用于为Linux系统(或者基于Linux内核的系统)提供 负载均衡 和 高可用性 功能。其负载均衡框架依赖于LVS(Linux Virtual Server)中的IPVS内核模块。 运行过程大致为:多台安装keepalived服务器共同虚拟出一个VIP(Virtual IP),客户端通过VIP进行访问。VIP会绑定在优先级最高的Master节点的网卡上。当Master节点出问题了,次优先级的节点会代替Master的位置,VIP会绑定到该节点的网卡上,这个过程称为 IP漂移 。 Example 准备两台机器(都安装上nginx): KL1:172.28.128.3 KL2:172.28.128.4 分别安装Keepalived: sudo yum install -y keepalived 安装完成后配置文件默认位置为 /etc/keepalived/keepalived.conf 让KL1作为 Master ,KL2作为 Backup ,分别配置: # KL1 keepalived.conf vrrp_instance VI_1 { state MASTER # keepalived角色,MASTER为主,BACKUP为备

Android Creating a memory resident input file that can be attached to an email

旧巷老猫 提交于 2019-12-29 05:58:44
问题 The final objective will be clear shortly. I want to create a file object and instead of getting data from a real physical file I want to provide the buffer myself. Then, I want to use this file, which does not really exist in the sdcard or anywhere outside my app, give it a name and send it by email as an attachment (using the EXTRA_STREAM). I found the following bit of code, by Adriaan Koster (@adriaankoster), the post Write byte[] to File in Java // convert byte[] to File

When should you call base.Method() in overridden method, and how to mark this when you write code in team?

蹲街弑〆低调 提交于 2019-12-29 04:30:52
问题 When using some framework/api, sometimes it's pretty unclear if you must call base.Method if you override it, for example you can be pretty sure that you should call base.Maethod() when you are overriding event invocater, to propagate the event, in other situations it can be not so clear especially when there is no source code available, and no comments. I wounder how other programmers decide should they call base method or not in this situation, and if you are about to write some framework

virtual function call from base class

不想你离开。 提交于 2019-12-29 02:45:10
问题 Say we have: Class Base { virtual void f(){g();}; virtual void g(){//Do some Base related code;} }; Class Derived : public Base { virtual void f(){Base::f();}; virtual void g(){//Do some Derived related code}; }; int main() { Base *pBase = new Derived; pBase->f(); return 0; } Which g() will be called from Base::f() ? Base::g() or Derived::g() ? Thanks... 回答1: The g of the derived class will be called. If you want to call the function in the base, call Base::g(); instead. If you want to call

Java与C++比较

独自空忆成欢 提交于 2019-12-28 19:38:16
本文仅从片面的角度比较Java与C++的一些特性,如有错误的地方,请指正。 语言特性上的一些差异: 1、Java没有无符号整数,C++/C#都有。 2、Java中不存在指针。Java的引用是功能弱化的指针,只能做“调用所指对象的方法”的操作,C#默认不使用指针,在unsafe标识时可以使用。 3、Java不能用双等号比较字符串(注意常量池中的字符串),C++/C#可以。 4、Java强制局部变量初始化。 5、Java不支持自动类型转换,必须强制类型转换。 6、Java和C#没有宏。 7、C++经过编译连接后生成二进制代码,C#生成MSIL,Java生成字节码。 8、Java和C#有垃圾回收机制(GC),C++需要手动释放资源,可能会因失误忘记释放资源而造成内存泄漏等问题(C++11提供智能指针来解决这一问题)。 类机制上的一些差异: 1、 Java是完全面向对象的,所有方法都必须写在类中,C++既可以面向过程也可以面向对象,函数不必须写在类中。为了避免命名重复与实现代码重用性,C++和C#使用命名空间,Java使用包。 2、 Java中有强制性异常(除RuntimeException外,必须在编译前处理),而C++没有。(C++ C# 和Java的捕获异常语法大体相同) 3、 Java所有对象都直接或间接继承自Object,并且提供接口机制,C++没有共同的基类。 4、

Multiple (diamond) inheritance compiles without “virtual”, but doesn't with

浪子不回头ぞ 提交于 2019-12-28 06:47:11
问题 Given the following code (without virtual inheritance) : class A { public: virtual void f() = 0; }; class B : public A { public: virtual void f() {} }; class C : public A { public: virtual void f() {} }; class D : public B, public C { /* some code */ }; int main() { D d; return 0; } the code compile. On the other hand , here : class A { public: virtual void f() = 0; }; class B : virtual public A { virtual void f() {} }; class C : virtual public A { virtual void f() {} }; class D : public B,

Multiple (diamond) inheritance compiles without “virtual”, but doesn't with

依然范特西╮ 提交于 2019-12-28 06:46:43
问题 Given the following code (without virtual inheritance) : class A { public: virtual void f() = 0; }; class B : public A { public: virtual void f() {} }; class C : public A { public: virtual void f() {} }; class D : public B, public C { /* some code */ }; int main() { D d; return 0; } the code compile. On the other hand , here : class A { public: virtual void f() = 0; }; class B : virtual public A { virtual void f() {} }; class C : virtual public A { virtual void f() {} }; class D : public B,

Can't get Mongoose virtuals to be part of the result object

寵の児 提交于 2019-12-28 06:17:14
问题 bI'm declaring a virtual that I want to appear as part of the results of its schema's queries, but it's not showing up when I do a console.log on the object. Here's the schema: var schema = new mongoose.Schema( { Name: { type: String } }, { toObject: { virtuals: true } }); schema.virtual("Greet").get(function() { return "My name is " + this.Name; }); Should that toObject not set the virtual as a property of the results of any queries? It does not, nor does schema.set("toObject", { virtuals:

What are the performance implications of marking methods / properties as virtual?

假如想象 提交于 2019-12-28 03:29:10
问题 Question is as stated in the title: What are the performance implications of marking methods / properties as virtual? Note - I'm assuming the virtual methods will not be overloaded in the common case; I'll usually be working with the base class here. 回答1: Virtual functions only have a very small performance overhead compared to direct calls. At a low level, you're basically looking at an array lookup to get a function pointer, and then a call via a function pointer. Modern CPUs can even

Eclipse with ADT的安装和配置

此生再无相见时 提交于 2019-12-26 15:51:25
我们从安卓官方网站( https://developer.android.com/sdk/index.html#download )下载下来的eclipse是捆绑好了ADT的,所以不用自己安装插件,十分方便。 我们先在解压缩后的目录下建立一个空的文件夹——virtual,用来来存放虚拟机。 然后,在我的电脑上右键->属性,进入环境变量,设置键为: ANDROID_SDK_HOME ,值为virtual的目录名:D:\WorkAppliactions\adt-bundle-windows-x86-20140624\virtual(根据自己的安装路径来设置) 来源: https://www.cnblogs.com/tianzhijiexian/p/3859446.html